My situation
I am currently using Cache Busting when I include CSS files like this:
echo "<link href='stylesheet.css?" . filemtime('stylesheet.css') . "' />"
My goal
Now I would like to do something similar for the images I am including inside my CSS file.
The problem
The problem is that I cannot use PHP inside my CSS files and I would rather keep my CSS files seperated.
My question
How can I add the filemtime()
to the images inside my CSS files while keeping the files seperated?
Edit
I would like to use Far Future Expires headers to cache the files.
You could actually rename your css files as style.css.php and then use PHP inside them. As long as the post-processing result is in the proper CSS format, it should work. I've done it in the past. I'm not sure if it's necessary, but if that gives you problems, you can use a header('Content-type...') kind of thing and ensure it's sent as a CSS file.