Lasso Soft Inc. > Home

[pk_autoversion]

Linkpk_autoversion
AuthorPier Kuipers
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted20 Feb 2012
Updated20 Feb 2012
More by this author...

Description

This tag is based on an idea posted on StackOverflow, on how to force-refresh CSS files: http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files#118886 Requires rewrite rule in apache config as follows: RewriteRule ^(.*)\.[\d]{14}\.(css|js)$ $1.$2 [L]

Sample Usage

[pk_autoversion('/css/screen.css')] ->
'/css/screen.20120219213351.css'

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

/*
================================================================================
This tag is based on an idea posted on StackOverflow, on how to force-refresh CSS files:
http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files#118886
Requires rewrite rule in apache config as follows:
RewriteRule ^(.*)\.[\d]{14}\.(css|js)$ $1.$2 [L]
================================================================================
*/
if(!lasso_tagexists('pk_autoversion'));
    define_tag('autoversion',
        -namespace = 'pk_',
        -required='filename',
        -description='Changes a requested CSS or JS filename to include a datestamp string');
        local('output'=string);
        local('versionstring' = (date(file_moddate(#filename))->format('%q')));
        #output = string_replaceregexp(#filename, -find='^(.*)\.(css|js)', -replace='\\1.'#versionstring'.\\2');
        return(@#output);
    /define_tag;
/if;

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft