View previous topic :: View next topic |
Author |
Message |
checat Smarty Rookie
Joined: 05 Feb 2004 Posts: 13 Location: Russia, Saint-Petersburg
|
Posted: Thu Feb 05, 2004 4:10 pm Post subject: Cache regeneration and Last-modified header |
|
|
It could be good if when Smarty regenerate "old" cache, it check if new cache content is the same with the old cache content, then save old Last-modified time if content was not modified, but prolongate cache validness.
It will need to split cache last-modified time into two variables "last-regenerated" and "last-checked-for-correctness"
It should have benefits for users often visiting rarely modified pages, and for search engines, which remember HTTP last-modified date.
Another interesting possibility: programmer could supply his own last-modified date for a page, to show its content real modification date. |
|
Back to top |
|
checat Smarty Rookie
Joined: 05 Feb 2004 Posts: 13 Location: Russia, Saint-Petersburg
|
Posted: Wed May 12, 2004 3:57 pm Post subject: I'd like to extend my idea |
|
|
I'd like to extend my idea. There is an important sphere of Web development called "Search Engine Optimization". I read that many search engines make use of Last-Modified date of document. Some of them try to show the date of document along with the search resullts. The way Smarty caching works looks unfriendly to them.
I suppose Smarty can be changed so caching could rely on both Last-Modified and ETag headers, with programmer's decision which of them to use.
I see the logic so: calculate some checksum (md5 or crc32) of cache content (can be saved within cache info) and use it as ETag header (or as weak ETag header if cache content uses inserts) for output and for validation of conditional HTTP requests.
This way conditional requests are still working and even extends a bit because of possible weak validation (actually I don't know if browsers and proxies make difference of weak and strong ETag), but Last-Modified header becomes free for more useful information, the last-modified date of its content part. For example, a news site could output the publish date of news.
If Smarty core developers agree with my points, I think, I can make a patch with necessary changes.
At least, two methods sendHTTPValidators($_cache_info) and checkHTTPValidators($_cache_info) should be extracted from fetch(...) method. Then any developer (like me) will have a possibility to override those functions in a custom child class to change the functionality. For now, I don't like an idea to override the whole display() method.
Any feedback is very appreciated. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed May 26, 2004 8:42 am Post subject: |
|
|
this sounds like a good thing.
only one point: providing emtpy methods to be overridden by a subclassed Smarty would be a whole new paradigm for smarty to be extended. maybe a callback-function as configuration-variable (like done with $smarty->cache_handler_func ) would fit better into current Smarty. (although providing virtual methods would be the obvious way to go from an OO point of view).
greetings
messju |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed May 26, 2004 9:15 am Post subject: |
|
|
I wonder if core plugins are appropriate for this. |
|
Back to top |
|
electr0n Smarty Rookie
Joined: 26 Mar 2004 Posts: 32 Location: Germany
|
Posted: Fri May 28, 2004 6:08 pm Post subject: |
|
|
boots wrote: | I wonder if core plugins are appropriate for this. |
I think they are, just put a md5 field into the cache header and check these.
That should be a great thing.
**edit**
Forget about the md5, I've got a better idea. How about saving a md5 of the template variables, prefilter and so on, in the cache header?
That's a quite simple way to check if the files need to be recreated. |
|
Back to top |
|
dodtracker Smarty n00b
Joined: 17 Jun 2007 Posts: 4
|
Posted: Sun Jun 17, 2007 6:12 am Post subject: Smarty support for browser caching |
|
|
Was the feature to use ETags and Last-Modified (and using the if-modified-since or if-none-match sent by the browser to return 304 not modifieds) implemented? Does smarty have explicit support for browser caching?
Let me know; I have some code to do this before I came across Smarty, and I can create a simple child class of Smarty that does this, or I could add this to the core code.
Seems that, since Smarty has it's own HTML cache, this is a logical (and important) part of making the client experience with Smarty as fast as possible.
Thanks!
Ben
http://www.dodtracker.com/ |
|
Back to top |
|
checat Smarty Rookie
Joined: 05 Feb 2004 Posts: 13 Location: Russia, Saint-Petersburg
|
Posted: Mon Jun 18, 2007 10:24 am Post subject: Last-modified |
|
|
Hi dodtracker!
Smarty makes use of Last-modified and If-modified-since headers for a very long time. If caching is turned on, it compares cache modification date with Last-modified header in "display()" method.
Ideas in this topic were to improve caching mechanics to provide longer periods of "cache equality hits" making it independent of cache update period. I've abandoned this task because my sites become more and more dynamic.
Smarty never use ETag (if I didn't miss something last year). |
|
Back to top |
|
|