1

I know that about 10 years ago it was wrong to use querystrings for cache busting.

This post is often referenced: http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/

Is this still relevant? Should I still prefer filename change over querystring?

guy mograbi
  • 27,391
  • 16
  • 83
  • 122

1 Answers1

2

Starting from releases 2.7 and 3.1 Squid supports responses to requests with query by default. However, I don't see any advantages of query over path. And since there may be someone who uses old version of Squid or some other proxy that doesn't support this, I probably would use path to specify resource version.

Relevant quote from squid-cache wiki:

The obsolete default configuration of squid prevents the caching of dynamic content (pages with ? in the URI) ....

NOTE: That policy setting was created at a time when dynamic pages rarely contained proper Cache-Controls, that has now changed. From the release of Squid 2.7 and 3.1 the squid developers are advocating a change to this caching policy. These changes will also work in 3.0 and 2.6 releases despite not being officially changed for their squid.conf.default.

Relevant comment to article you linked by Leif Hedstrom:

.... there might be intermediaries between the UA and the origin, which do not allow this. E.g. transparent ISP proxies, corporate firewall proxies, etc. So, the advice is still good, you are better off versioning on the filename.

For more information check:

Community
  • 1
  • 1
Leonid Vasilev
  • 11,910
  • 4
  • 36
  • 50
  • 1
    "I don't see any advantages of query over path" - path requires to sync between filenames and their references, while query parameters do no. Query parameters are perfect when you reference a resource dynamically in code - for example /img/ticket-{{type}}.svg?v=__cachebust__ – guy mograbi May 04 '17 at 19:36
  • How do you generate `__cachebust__`? – Leonid Vasilev May 05 '17 at 11:32
  • whatever uniquely identifies a "version". Some simply use timestamp, but if you have a BUILD_ID for example - that's better - or even a git hash. In some cases I do use MD5 of the file to improve caching of unchanged files. – guy mograbi May 05 '17 at 18:32