Wordpress plugins
Filename based asset cache busting

Filename based asset cache busting

Version : 1.4
Tested up to : 5.4
Number of download : 558
Average rating : 5 / 5 on 5 votes 5 votes, 5 avg.rating

Screenshots

Filename based asset cache busting
Filename based asset cache busting
Filename based asset cache busting
Filename based asset cache busting

Filename based cache busting for WordPress scripts/styles using last modified date. Based on this gist https://gist.github.com/ocean90/1966227 from Dominik Schilling, I’ve enhanced it by automatically replacing the asset version with the files modification time and automatically editing htaccess – making it install + forget. Not also includes querystring option as a fallback – less good but also less error prone. Host specific notes Some webhosts need a bit of custom config to get the filename based urls working. Apache The plugin should add what it needs to your .htaccess file jsut like WP itself. But if for any reason that doesn’t work for you – here’s what it adds: # FBACB <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.([0-9\.]+)\.(js|css)$ $1.$3 [L] </IfModule> # still fbacb <IfModule mod_expires.c> ExpiresActive on ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" </IfModule> # END FBACB WP Engine To work on WP-Engine, you’ll need the following redirect added via my.wpengine -> installname -> Redirect rules Source: ^(.+).([0-9.]+).(js|css)$ Dest: $1.$3 Type: break (this is under advanced) PHP Fallback If your webserver is failing to serve assets using url rewriting, the plugin attempts to serve them itsef (ie: via PHP). Obviously this is slow/less than ideal in production (it’ll be much slower) – so you should configure your web server correctly to serve the files. If you see this HTTP header “FBACB-Php-Fallback: yes” on your assets, this applies to you. Note that hosts are inccreasingly configured to serve css/js directly from disk and won’t fall back to PHP + WordPress error handling – this fallback then won’t work.

Download now