Is there any reason why I'd be getting a 404 error from a CSS file with a version number on the end of it?
<link rel="stylesheet" href="styles/main.css?v=123">
My file is also named main.css?v=123
.
Any help is appreciated. Thanks in advance!
Is there any reason why I'd be getting a 404 error from a CSS file with a version number on the end of it?
<link rel="stylesheet" href="styles/main.css?v=123">
My file is also named main.css?v=123
.
Any help is appreciated. Thanks in advance!
You should rename your file to just main.css
, then in the html reference it like this: <link rel="stylesheet" href="styles/main.css?v=123">
You'll only need to change the version in the HTML after you've updated your css. Remember, your css file will always be named just main.css
Hope that helps!
Just to clarify this is called querystring caching. You add the querystring in the HTML only. When you change it most browsers will assume it's a new file and reload it regardless of how you set the cache for CSS files.
It's possible to do this via PHP without having to manually change it every time you change the css file.
<link rel="stylesheet" href="styles/main.css?t=<?php echo filemtime( 'styles/main.css'); ?>" type="text/css" media="screen" />
This appends the css files modification time to the HTML. Every time you save the CSS file this will update automatically.
By this type of link, you passed to browser the HTTP request GET
, with argument v
and its value 123
. Server is still looking for main.css. The 404
code means page not found.
If you want to server handles it use URL-rewriting.
Or you can try encode the question mark by typing %3F
.
Please note that file names containing question marks aren't allowed on windows and MSDOS systems.