On Jun 2, 2005, at 1:36 AM, Dries Buytaert wrote:
On 01 Jun 2005, at 18:32, Nicholas Ivy wrote:
2. Page elements poll the cache for every page request. When a page is loaded, the page element computes a cache key and checks for cached results. For example, in nodelist.module I used an md5-checksum of the sql query as a cache key. If the sql query changes, the cache misses. In this case, the challenge is to efficiently compute accurate cache keys and handle stale results, but at least we don't have to worry about every event in the system.
Do you suggest we render the page, compute and md5-sum on the generated HTML, drop the generated page on the floor, and serve the page from the cache? Or do you suggest computing the md5-sum on something else? I don't understand how that could work ...
No, I am not suggesting that we render pages and throw away the results. I am suggesting we compute the cache key using something else, something that will have to be identified per page element. Near the top of a block of code, we could use input values as cache keys to see if we have done this work already. If so, we skip the rest of the block and return the cache. I see a couple problems with this scheme, however. 1. We need to identify the important inputs that characterize the output. 2. We need to check early enough in the code for a cached result in order for the work to be worthwhile. As for nodelist.module, I looked again at how db_rewrite_sql() works and realized I got it wrong -- the structure of the query doesn't change per user. I thought I had an input to the page that completely characterized the result, but I really don't. So I'll have to work on that. Nic