1

Why do use like this filename.css?2 or filename.js?4 What are those numbers after question mark?

I did research online but I didn't find any answer.

Thanks!

2
  • It is revision numbers or cache busters as listed below. When people release a new version of their javascript, they increment this by one to force people to grab the latest version of their JS. Commented Sep 8, 2014 at 22:58
  • You say you did research online, yet when I copy/paste the first line of your question into Google, we get the answer: stackoverflow.com/questions/4044085/… Odd. Commented Sep 8, 2014 at 23:08

2 Answers 2

7

These are called cache busters.

Usually, when a browser downloads a file (CSS, JS, etc.) it caches it so that it doesn't have to download it later.

However, this is a problem when you decide to update your file, because the browser thinks it already has the latest version. To work around it, we use the cache busters. When you make a change to the file, you also change the number after the question marks, which tricks the browser into thinking this is a different file for which it doesn't have a cache it, and forces a re-download.

Sign up to request clarification or add additional context in comments.

14 Comments

@C-link Nepal, mind telling what is wrong?
They say pretty much what I said. So, again, do you mind pointing exactly what is wrong?
If you read carefully, that's exactly what I said.
But that's what it does. I'm not saying it is because of the cache buster, I'm simply saying the browser does it. I'd recommend you read it more carefully.
OK, you clearly can't interpret what I'm saying. Never mind then.
|
0

Sometimes JS scripts are created on the fly using server side technologies other times it is simply a version number to help with browser caching issues

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.