Table of Contents
If you ever do a page speed check on your site, you may have seen the notice to “Remove query strings from static resources.”
What Are They And Why Do I Care? What Are They And Why Do I Care?
At their most basic, a query string is any URL that has a
? in it. For example, if you go to a url of
https://example.com/?lang=en then that last bit is the query string. It’s job is to tell the browser to pass on specific information to the website. It’s essentially a variable that will be read by the website or the browser.
However. The explanation is that browsers don’t cache anything with a query string. Which means, yes, if your static resources have one, they won’t get cached.
Or will they? (It’s complicated.)
Why Do My Resources Have Query Strings? Why Do My Resources Have Query Strings?
https://example.com/wp-includes/js/jquery/jquery.js and that has no version number. But WordPress has certainly updated that a number of times.
In order to make sure that jQuery gets properly cached when you upgrade, WordPress adds a query variable like this:
This is important because otherwise when you upgraded WordPress, you’d see a page formatted weirdly and misbehaving, all because the wrong (cached) jQuery was loaded.
Should I Remove The Query Vars? Should I Remove The Query Vars?
Yes, allowing your resources to be cached will make your site faster, and it will get you a higher score in those page speed checks. At the same time the speed benefit is pretty low compared to the dangers of those files not being properly updated. Features on your site will, literally, cease to function.
So you’ll need to decide for yourself which is more important.