Forum Moderators: phranque

Message Too Old, No Replies

File Caching

         

keyplyr

9:43 am on Jun 29, 2009 (gmt 0)

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



Hosting company has ExpiresActive disabled and they have no suggestions how I can control file caching. Tests show that a browser needs to make 21 additional connections because absence of cache control (hosting company does not have any defaults set.)

I'm thinking of adding it to the page header using the auto_prepend_file in my php.ini. I already prepend my P3P abbr. tags.

Can I add an additional line to the php.ini with another file prepended? Or is it best to just cram the caching code into the existing file along with the P3P statement?

Also, in RegEx my caching statement looks like this:

ExpiresActive On
ExpiresDefault A21600
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
<FilesMatch "^(error\.html¦forbidden\.html¦authentication\.htm)$">
ExpiresDefault A0
</FilesMatch>

How would I write it to be included in the header? Thanks.

jdMorgan

1:53 pm on Jun 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Modify the script that you use to serve images to output the following additional HTTP headers for images:

Cache-Control: max-age=2592000, public
Expires: Mon, 29 Jul 2009 13:53:05 GMT

Note that you will have to re-calculate the "Expires" date and time for each request. Start with the current "Unix time", add 2592000 seconds, then convert to standard HTTP time.
Both headers must be output (along with the Content-Type header that you're probably already outputting) before any content is served.

For non-image (page and script) resources, it looks like you want something like:


Cache-Control: must-revalidate, max-age=21600
Expires: Mon, 29 Jun 2009 19:53:05 GMT

Jim

keyplyr

5:19 am on Jun 30, 2009 (gmt 0)

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



Alright, thanks Jim.