Force CSS cache to refresh via file?

Hi there,

I have a CSS file that is included on every page of my website. Is there a way I can force this file to refresh it’s cache via the file itself? I have so many pages so it would be so time consuming to add a versioning attribute to the end of the include.

Any ideas?

Thanks!

It can be automated server side.

PHP

$csstime = date ("Y-m-d\TH-i", filemtime($_SERVER["DOCUMENT_ROOT"] . '/css/style.css'));

Then:-

<link rel="stylesheet" type="text/css" href="css/style.css?update=<?php echo $csstime ?>">

This will cache, but refresh when changed.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.