Does having a query string attached to a URL cause browsers to never cache it? For instance, my site does something like this:


And it would appear that FireFox never caches that picture; it is downloaded on every request.

I'd like FireFox to cache it, for as long as it wants to. I only want to force it to download when the v= parameter has changed.

  • 1
    I guess you could accomplish this, if you just change the filename itself instead of the query. So now the filename would be radar-picture-sep2013.png and when it changes at some point in the future it would be radar-picture-jan2014.png. You can configure the PNG's max-age to a year so unless the filename changes, the browser can load the cached picture for a long time.
    – vstm
    Commented Sep 11, 2013 at 18:07

2 Answers 2


Adding a query-string key/value pair to a static resource (such as an image, CSS or JavaScript) can cause caching issues.

Specifically, since you mentioned Firefox, your issue could be related to a 'Cache collision', where:

The Firefox disk cache hash functions can generate collisions for URLs that differ only slightly, namely only on 8-character boundaries. When resources hash to the same key, only one of the resources is persisted to disk cache; the remaining resources with the same key have to be re-fetched across browser restarts. Thus, if you are using fingerprinting or are otherwise programmatically generating file URLs, to maximize cache hit rate, avoid the Firefox hash collision issue by ensuring that your application generates URLs that differ on more than 8-character boundaries.

[Source: https://developers.google.com/speed/docs/best-practices/caching ]

  • 7
    What is "8-character boundary" and HOW can I avoid this collision? How should my URLs look like then?
    – Andrew
    Commented May 10, 2016 at 17:49

This answer on stackoverflow claims that some browsers react differently to hitting enter in the address bar vs clicking on a link when the url has a query string: https://stackoverflow.com/a/85386/1145388

When you are testing, make sure you are clicking on links rather than refreshing or hitting enter in the url bar.

  • 2
    I think that answer on stackoverflow may be outdated. When I put a query string on stylesheets style.css?v=sep2013 and the 150KiB background-image:url('bgimage.jpg?v=sep2013');, navigating the site (via clicking links, or typing in address-bar) is very slow in FireFox.
    – Mr. Smith
    Commented Sep 11, 2013 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.