Forum Moderators: coopster

Message Too Old, No Replies

How would I create a simple cache of this php page?

         

JS_Harris

10:43 pm on Jan 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a single php page that when opened makes 30 calls to an affiliate server to retrieve updated images and details etc.

I'm including this page in several places on my site via iframe but it is independent from the sites cms and is a good candidate for individual caching.

The problem is that traffic is launching this page a lot of times every minute so the 30 calls per pageload is resulting in a LOT of affiliate server calls, too many.

I'd like to cache the page so that it is loaded just once per hour and a cached copy is served the rest of the time.

Is there some simple code I can place in the header of this page to generate this hourly cache function?

I'm looking for as SIMPLE as possible, I'm not interested in installing large scripts etc..etc. Ideally I can have all of the cache related code added to that single page.

How ?

eelixduppy

11:35 pm on Jan 3, 2009 (gmt 0)



You can change the headers using the header [php.net] function.

Something like this maybe:


header('Cache-Control: max-age=3600');
header('Expires: '.gmdate('D, d M Y H:i:s', time()+3600).' GMT');