What are these things in css files?

Viewed 40

I recently downloaded wordpress and I realized that on the installation page the css files it has, wordpress implements them like this:

 wp-includes/css/dashicons.min.css?ver=6.0.2

What is the ver=6.0.2 in the url? What happens if that part is removed? Or just how does it work?

2 Answers

(Almost) anything that follows a ? (question mark) in a URL is part of this data called a "query string". Query strings allow you to pass data to the server via the URL without changing the target page.

Query strings are in a key-value format delimited by & and the key and value delimited with =, so a URL with a query string would look something like https://example.com?data=something&otherdata=something+else.

As an example: StackOverflow utilizes query strings to read what you've searched for and access it from the server, like this: https://stackoverflow.com/search?q=query+string.

Another note is that if the server doesn't recognize a query string you've provided, it is generally ignored, so if I go to https://stackoverflow.com?random=querystring you'd still end up on the home page.

In your case, I would surmise that you are passing a version number either for the version of CSS (caching might prevent updates; passing a different querystring evades cache) or the Wordpress version you're currently using so that the server can send the relevant CSS.

That's a query string (cf. RFC 3986 Section 3.4)

Wordpress is using the query string as a cache buster. Browsers might not download a file again and use their locally cached version if they think the file has not changed. Since the content of the file changes with each version, but its name does not, Wordpress is appending the query string with the version so that browsers are informed that they must download the file again (different URI, so cache is not used).

Related