Smarter caching needed
| From: | Tom Anderson | Date: | Fri, 27 Jun 2003 17:40:07 +0000 |
| Subject: | Smarter caching needed | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1706@lists.php.net to get a copy of this message | ||
Hey all,
My site (http://db.etree.org) uses smarty to cache many pages. Among these
is the front page which is refreshed every 5 minutes. I get between 9 and
10 million hits/month and my front page is the launching point to do
pert-near everything on the site. Because of this, the front page gets a
lot of hits.
The front page has some very complicated queries on it which can take a bit
of time to complete, especially _if multiple people request the page between
the time the cache has expired and a new copy is put in place_.
So: I would enhance smarty to eliminate this problem. I've got few ideas
on how to do this. I'd like some input on my best so far, if you would:
When a page is going to be refreshed, rewrite the cached copy's header to
include a 'refresh start' time. When a cache check is done and it is
determined that the cached copy has expired the refresh start time will be
checked against a new smarty property of 'refresh wait' time. The refresh
wait will be, say, 1 minute. If a refresh start doesn't exist than that
process will continue and regenerate the page. If the refresh start does
exist and the refresh wait time has not passed, the cached version of the
page will be displayed instead of refreshing the page.
What do you think? Hare-brained or a good idea? Got a better solution?
Also, when is a cached file deleted and a new one overwritten? I think the
cached file should be deleted immediatly before the new one is
overwritten...I'll browse the code for my answer but thought I may get a
quicker one by asking here.
Thanks,
Tom