Help with ETags and caching with PHP Includes

wolf99

Member
Messages
38
Reaction score
0
Points
6
Hi folks

I am new to the business of fiddling wit http headers and wondered if someone could help me or give a few pointers on it.

I am on free account and using .htaccess, have a few redirects for SEO freindly urls. Are ETags automatically generated or do I need to turn them on somehow?

How should I then configure the caching to, say keep content for a week unless the ETag has changed (indicating a file update).

I have the added complication that I use a small bit of PHP in my main page to switch in the main content based on the ID passed in the URL.
Will the included content be controlled by the including pages headers?
How can I set the caching instructions for the included content?

Thanks for any help, I am a n00b to this area, so pointers much appreciated :)
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
If you want to know whether ETags are enabled, check. Request a page and examine the headers. To enable ETags, use the FileETag directive. For example,
Code:
FileETag MTime Size
ETags are only generated for static pages, since content of dynamic pages can change even if the inode, modification time and file size don't. You'll need to generate your own validators (e.g. ETag, Last-Modified) and Cache-Control header for dynamic content.

To control caching, use the Cache-Control header, setting the max-age and must-revalidate directives. If you want caches to revalidate the content and check the ETag, set max-age to 0. Otherwise, the cache will only validate once max-age is reached.

For more information, read Mark Nottingham's Caching Tutorial and sections 13 and 14.9 of the HTTP/1.1 spec, RFC 2616.
 
Last edited:

wolf99

Member
Messages
38
Reaction score
0
Points
6
Hi Misson

Thanks for the info, very helpfull. have actually been working my slow little way through Mark's article, but some of it is still trickling over my head :redface:.

I will read the other reccomendations also and let you know how I get on.
Thanks again
 
Top