Caching

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

Caching

Post 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
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Caching

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Caching

Post 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.
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

Re: Caching

Post by Monotoko »

But surely I'm caching on the local machine? Which means it will be their time, or is my logic screwed?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Caching

Post by Jonah Bron »

Oh, that kind of caching :roll:

Code: Select all

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