Hey everyone!
So today I created an addon for CouchCMS that will automatically take a filename and add its timestamp to it. This way, if you have caches enabled in your .htaccess (not the cache that's set in config.php, but header caches set in .htaccess) you can have automatic cache-busting.
The way it works is like this:
This will come out as:
The "1234567" would actually be the timestamp of the file. So whenever you change the file, the url automatically changes. You'll need to add the following to your .htaccess to make this redirect normally:
This will work for all of the file extensions listed above. You can add your own if you need them.
If anyone has any suggestions or corrections to the addon, please let me know...I'm new at this lol
So today I created an addon for CouchCMS that will automatically take a filename and add its timestamp to it. This way, if you have caches enabled in your .htaccess (not the cache that's set in config.php, but header caches set in .htaccess) you can have automatic cache-busting.
The way it works is like this:
- Code: Select all
<img src="<cms:cache_buster 'the/path/to/your/file.extension' />" />
This will come out as:
- Code: Select all
<img src="http://yoursite.com/the/path/to/your/file.1234567.extension" />
The "1234567" would actually be the timestamp of the file. So whenever you change the file, the url automatically changes. You'll need to add the following to your .htaccess to make this redirect normally:
- Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
</IfModule>
This will work for all of the file extensions listed above. You can add your own if you need them.
If anyone has any suggestions or corrections to the addon, please let me know...I'm new at this lol