Gzip and caching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Unicron
    New Member
    • Apr 2007
    • 8

    Gzip and caching

    Hi folks, I couldn't find any posts about this issue-

    I am using Firebug to examine my page loading. When I call a large JS file, it gets downloaded once and then shows as being cached the next time I go to the page.

    For example, it shows "9 requests 100 KB (90 KB from cache)"

    However, if I change the JS file to a PHP file with GZIP, it compresses that 90KB file down to 20KB, but never says it pulls it from cache. The Firefox "about:cach e" page shows that each time the page loads, the fetch count on that file goes up.

    I am wondering- is this gzipped file being repeatedly downloaded, or just checking that the file is still the same? If it is being downloaded again, is there a different header I can send to make it work?

    Here is the PHP I am using for the gzipped javascript (see to expire 1 year)

    [PHP]
    ob_start("ob_gz handler");
    header("Content-type: text/javascript; charset: UTF-8");
    header("Content-Encoding: gzip");
    header("Cache-Control: must-revalidate");
    header("Expires : ".gmdate("D ,d M Y H:i:s",time() + 3600*24*365)." GMT");
    [/PHP]

    Thanks everyone!
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Unicron.

    I'm not terribly familiar with how browser cache headers work, but this article might be useful:

    Covers the how's and why's of Web caching for people who publish on the Web. With FAQs.

    Comment

    Working...