New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Version Query Parameter on Assets Links

Jesper Lund Nielsen September 19, 2014 by Jesper Lund Nielsen

Often I run into cache issues when I modify e.g. a stylesheet or javascript file, and it doesn't get reloaded in the visitors browser. This could be avoided by adding a version query parameter on assets links, which forces the browsers to reload the asset.

Right now a link tag looks like:

<link href="/_themes/mytheme/css/mystylesheet.css" rel="stylesheet">

by using:

{{ theme:css src="mystylesheet" tag="true" }}

The solution could be:

{{ theme:css src="mystylesheet" tag="true" versionquery="true" }}

and then the link tag would be:

<link href="/_themes/mytheme/css/mystylesheet.css?v12348589" rel="stylesheet">

The version query parameter should by a sanitized string of the last write time on the file.

Answered by Shane!
>>>>>>> Answered <<<<<<<
4 Replies
1 Follower