WP-Optimize
95Get caching and more with this powerful cache plugin. Cache, optimize images, clean your database and minify f...
Filename based cache busting for WordPress scripts/styles using last modified date.
Filename based asset cache busting is a WordPress plugin that automatically updates the URLs of CSS and JavaScript files based on their last modified date. This helps prevent issues with cached files, ensuring that users always receive the latest versions without needing to refresh their browsers manually.
The plugin modifies the .htaccess file to implement these changes and offers a query string option as a fallback. It is designed for users looking to improve their site's performance and Google Pagespeed scores by managing asset caching effectively.
Best for: This plugin is suitable for WordPress site owners who want to improve asset management and site performance.
What it does well
Where it falls short
Filename based asset cache busting offers a straightforward solution for managing cached assets in WordPress. It is particularly useful for those seeking to enhance site speed and user experience.
benlumley's own description of Filename based asset cache busting, lightly tidied.
Filename based cache busting for WordPress scripts/styles using last modified date.
Stop telling clients or users to hard refresh / shift refresh. The url to all of the css/js files on your site will change automatically whenever the files are modified. You can set proper long cache lifetimes to help get top scores on Google Pagespeed without running into cached css/javascript problems.
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.
Includes querystring option as a fallback – which works in more scenarios.
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
location ~* ^(.+)\.(?:\d+)\.(min.js|min.css|js|css)($|\?.*$) {
try_files $uri $1.$2;
}
Some webhosts need a bit of custom config to get the filename based urls working.
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)
Other plugins for making sites fast.
Get caching and more with this powerful cache plugin. Cache, optimize images, clean your database and minify f...
All-in-one unbeatable acceleration & PageSpeed improvement: caching, image/CSS/JS optimization...
Comprehensive image optimization with WebP, AVIF, Lazy Load, and more. Optimize images automatically for Faste...
Easy to use Under Construction Page & Coming Soon Page. Enable Under Construction Mode in seconds & sh...
Compress and optimize images, enable lazy load, serve WebP & AVIF, and speed up your site with a global im...
Speed up your website by using our WebP & AVIF Converter. Optimize images and serve WebP and AVIF images i...