Motyar

Freelance Web Developer

Say Hi

Jul 24, 2017

Auto versioning JavaScript and CSS files with PHP

While development stage, sometimes files get updated but browser doesn't reload the latest version of CSS and JS file and keep showing the cached version.

We can force to reload CSS and JS files by using current timestamp with the filepath, but its not a good idea to reaload files when nothing got changed.

Sharing a very simple hack that can be used to only reload the latest version when the files get changed.

path_to_js_or_css_file?<?=filemtime('path_to_js_or_css_file')?>


Labels: , , , ,




By :