Instead of generating links to file.js , I calculate the version number or hash amount and bind to file--bbe02f946d.js . I use the following redirection rule to then serve the current version of the file:
RewriteRule ^(.*)--[a-z0-9]+\.js$ $1.js
Now I want to set very far Expires headers for these requests:
ExpiresActive on ExpiresByType application/javascript "access plus 1 year"
This works fine, but it also applies to non-versioned resources ( /file.js requests). How to set expires header only for requests matching RewriteRule? I usually use <LocationMatch> , but this is not possible, since the application should work on arbitrary servers, where I can just change htaccess.
source share