Page 1 of 1

Caching

Posted: Tue Oct 12, 2010 1:32 pm
by Monotoko
Hi there,

I'm trying to develop an application in PHP and the problem is it keeps causing massive server load because it has to reload everything from external sources. How would I make the site cache it for 3 hours, then reload? I have found examples using the time, but surely the time is different in each country?

Daniel

Re: Caching

Posted: Tue Oct 12, 2010 3:10 pm
by twinedev
Depends on what data you are using, but you may want to look at using Smarty, which has this built in.

I've written something like this before, and when I get home from work, will post more on this (on a break right now).

I'll see if I can pull a sample for you.

-Greg

Re: Caching

Posted: Tue Oct 12, 2010 3:29 pm
by Jonah Bron
Monotoko wrote: I have found examples using the time, but surely the time is different in each country?
Yes, but you only have to deal with the timezone the server is in. The server doesn't change time automatically depending on where the request is coming from.

Re: Caching

Posted: Tue Oct 12, 2010 4:44 pm
by Monotoko
But surely I'm caching on the local machine? Which means it will be their time, or is my logic screwed?

Re: Caching

Posted: Tue Oct 12, 2010 5:21 pm
by Jonah Bron
Oh, that kind of caching :roll:

Code: Select all

header('Cache-Control: max-age=10800, must-revalidate');