How to remove query strings?
-
Hi,
I see that all static assets (like js and css) have some unique query string added to them, like
?c7c844-02...
and timestamps like?=_1444907..
.I would like to disable these so that more assets can be served from a CDN, which will improve the performance. Leveraging caching is also one of Google's recommendations for a faster web (and reduces the 'stress' on the server).
-
That's actually a cache busting strategy. When a js or css file gets changed, you don't want the old cached asset to be used any more, because it could cause weird behavior at best, and things to break completely at worst. The query string won't (and shouldn't) change if the file hasn't changed, so it's still using the same cached asset either stored locally or from the CDN
-
Thanks for responding.
@BDHarrington7 said:
That's actually a cache busting strategy. When a js or css file gets changed, you don't want the old cached asset to be used any more, because it could cause weird behavior at best, and things to break completely at worst.
That's true, but several query strings contain the timestamp and thus change every second. Those files don't change every second, of course, but only when I update NodeBB.
The query string won't (and shouldn't) change if the file hasn't changed, so it's still using the same cached asset either stored locally or from the CDN
Hm, for the css yes, but not for all js files. For example:
/vendor/jquery/timeago/locales/jquery.timeago.en-short.js?_=1445087543987
Reload after +/- 10 seconds:
/vendor/jquery/timeago/locales/jquery.timeago.en-short.js?_=1445087673969
Reload after another +/- 10 seconds:
/vendor/jquery/timeago/locales/jquery.timeago.en-short.js?_=1445087699505
This happens with two other JavaScript files too.
-
That means you're running on development mode, try running on production? That string doesn't change until you update NodeBB in prod