lastModified lastModified MODX Snippet Extra
lastModified

lastModified Guide

With this snippet you will have the ability to deliver the most recent version of any file.

When dealing with a browser's cache you can't be certain your viewers are getting the most recent copy. By appending a GET value (the UNIX timestamp) to, for example, a stylesheet, you can make the browser think the stylesheet is dynamic, thus reloading the stylesheet time the modification date changes.

That's all there is to it! Just view my page source for an example and live demo!


PROPERTIES
&path — string (req)
path to the file to give timestamp. Use trailing slash
&file — string (req)
filename of the document you wish to use

EXAMPLE
Give a file with a &path of `downloads/` and a &file name of `MyPackage.zip` With the &name of `My Package` and supports resume download while showing the hit count.
<link href="[[!lastModified?
   &path=`css/`
   &file='style.css'
]]" rel="stylesheet" type="text/css" >
Output:
<link href="css/style.css?1477050530"
rel="stylesheet" type="text/css" />