Content with Style

Web Technique

GET parameters and caching

by Pascal Opitz on January 7 2009, 16:55

Once you do care about caching and set expiry headers for static files in the far future, you'll have to make sure that crucial new functionality is not pulled from the cache. But a GET parameter is NOT the way to do this ....

Have a look into the HTTP protocol 1.1 specs about caching, and it becomes obvious why:

We note one exception to this rule: since some applications have traditionally used GETs and HEADs with query URLs (those containing a "?" in the rel_path part) to perform operations with significant side effects, caches MUST NOT treat responses to such URIs as fresh unless the server provides an explicit expiration time. This specifically means that responses from HTTP/1.0 servers for such URIs SHOULD NOT be taken from a cache.

People have tested this, and the bottom line is that you should change the filename instead. Interestingly (I didn't verify this, btw.) it seems that Firefox and IE just ignore this part of the spec sometimes, while Safari does it the right way.


  • Yes, good post.

    And good suggestion: Change the file name

    Another option: You can also change the path to the file name by injecting a date, or version number etc and URL Rewrite accordingly:

    by Anup on January 7 2009, 23:02 #

  • Yes Anup, that\'s of course another good option.

    I strongly suggest to implement changing the version numbers in a dynamic way. This could be PHP or it could go into the build tool, if you\'re using one!

    by Pascal Opitz on January 8 2009, 20:45 #