Situation: My CSS was getting cached which was really annoying so I solved it this way
<link rel="stylesheet" href="/css/screen.min.css?{$smarty.now}" type="text/css" />
But now it reloads it every single time, what I want now is to only reload when there are changes.
So, what I was thinking was instead of {$smarty.now}
use something that gives me the latest revision date/time.
Question:
How do I get the latest revision date/time from my css file with php/smarty/javascript?
You could use php's filemtime()
. This function will get the last modification time of your file, which wouldn't change unless changes were made to the file.
You would do something like:
<link rel="stylesheet" href="/css/screen.min.css?{$filemtime("/css/screen.min.css")}" type="text/css" />
The first forum item for this function in the documentation is a exact solution for your problem.