+ Reply to Thread
Results 1 to 3 of 3

Thread: Help with ETags and caching with PHP Includes

  1. #1
    wolf99 is offline x10Hosting Member wolf99 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    33

    Help with ETags and caching with PHP Includes

    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

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Help with ETags and caching with PHP Includes

    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 by misson; 05-24-2010 at 03:30 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    wolf99 is offline x10Hosting Member wolf99 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    33

    Re: Help with ETags and caching with PHP Includes

    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 .

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

+ Reply to Thread

Similar Threads

  1. Caching in SMF
    By smartflight in forum Free Hosting
    Replies: 3
    Last Post: 03-16-2010, 11:40 AM
  2. PHP caching
    By zordon19 in forum Programming Help
    Replies: 0
    Last Post: 12-17-2009, 07:08 AM
  3. About web caching
    By radofeya in forum Programming Help
    Replies: 6
    Last Post: 07-17-2008, 12:47 PM
  4. Caching Questions
    By Veridis in forum Programming Help
    Replies: 9
    Last Post: 04-11-2008, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers