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 based on version_date

 
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 -> General
View previous topic :: View next topic  
Author Message
Hpatoio
Smarty Rookie


Joined: 29 Apr 2003
Posts: 25
Location: Italy

PostPosted: Fri Oct 29, 2004 8:10 am    Post subject: Cache based on version_date Reply with quote

Hello.

- I have a page that list the content of a table and when the user click on "detail" the detail page is displayed Very Happy (hard to guess)

The point is that the "detail page" makes a lot of math operation with the detail data and this stress quite a lot my server.

What I want is to cache the "detail page" until the data are modified.

I explain more :

In my table I have a "version_date" field that contain the timestamp of last time the data of that row where modified.

I would like to have something like :

Code:

if ( $version_date_of_the_row < timestamp_of_the_cache_file) {
   
   Display the cache version of the page

} else {

   Create a new cache version of the page and display it

}


So, the question is : How do I get the timestamp of the cached file Question

Simone

PS: Something else in the manual, at the page where you explain how to write a custom "$cache_handler_func" (http://smarty.php.net/manual/en/section.template.cache.handler.func.php) the variable "$cache_contentS" shouldn't be "$cache_content" (no S at the end) at the line :

[php:1:a3effc0a94]<?php
$cache_contents = gzuncompress($row["CacheContents"]);
?>[/php:1:a3effc0a94]
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: Fri Oct 29, 2004 10:05 am    Post subject: Re: Cache based on version_date Reply with quote

hello,

you can't get the cached-files timestamp with smarty's api.

you'd have to use your own cache-handler functions, then you know where you store that info and thus should know how to retrieve it Smile

another way: just clear the corresponding cached template when you update the data-row.
then the cached page will be re-generated as soon as somebody asks for it.


Quote:
PS: Something else in the manual, at the page where you explain how to write a custom "$cache_handler_func" (http://smarty.php.net/manual/en/section.template.cache.handler.func.php) the variable "$cache_contentS" shouldn't be "$cache_content" (no S at the end) at the line :

[php:1:03a72355ea]<?php
$cache_contents = gzuncompress($row["CacheContents"]);
?>[/php:1:03a72355ea]


ah, thanks for pointing that out. i fixed it in the cvs of the docs. it will be in the online-manual after the next manual-rebuild (whenever this may be Smile )

greetings
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hpatoio
Smarty Rookie


Joined: 29 Apr 2003
Posts: 25
Location: Italy

PostPosted: Fri Oct 29, 2004 12:18 pm    Post subject: Re: Cache based on version_date Reply with quote

messju wrote:
hello,
you'd have to use your own cache-handler functions, then you know where you store that info and thus should know how to retrieve it Smile


I don't know what you mean, how do I call my custom_handler_function to have the cache timestamp ?

I thought I had to call

[php:1:cb9b805291]<?php
$smarty->is_cached("my_template.tpl");
?>[/php:1:cb9b805291]
to know if my template is cached or not ... but I don't see any way to overwrite the function "is_cached".

Is this possible ?

messju wrote:

another way: just clear the corresponding cached template when you update the data-row.
then the cached page will be re-generated as soon as somebody asks for it.

I thought about ... but the row is not updated by a PHP script.
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 -> General 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