Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Cache regeneration and Last-modified header

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
checat
Smarty Rookie


Joined: 05 Feb 2004
Posts: 13
Location: Russia, Saint-Petersburg

PostPosted: Thu Feb 05, 2004 4:10 pm    Post subject: Cache regeneration and Last-modified header Reply with quote

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
View user's profile Send private message Visit poster's website
checat
Smarty Rookie


Joined: 05 Feb 2004
Posts: 13
Location: Russia, Saint-Petersburg

PostPosted: Wed May 12, 2004 3:57 pm    Post subject: I'd like to extend my idea Reply with quote

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
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed May 26, 2004 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed May 26, 2004 9:15 am    Post subject: Reply with quote

I wonder if core plugins are appropriate for this.
Back to top
View user's profile Send private message
electr0n
Smarty Rookie


Joined: 26 Mar 2004
Posts: 32
Location: Germany

PostPosted: Fri May 28, 2004 6:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
dodtracker
Smarty n00b


Joined: 17 Jun 2007
Posts: 4

PostPosted: Sun Jun 17, 2007 6:12 am    Post subject: Smarty support for browser caching Reply with quote

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
View user's profile Send private message
checat
Smarty Rookie


Joined: 05 Feb 2004
Posts: 13
Location: Russia, Saint-Petersburg

PostPosted: Mon Jun 18, 2007 10:24 am    Post subject: Last-modified Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP