这是我在 Apache httpd.conf 中为图像、JavaScript 和 CSS 启用缓存的方法
<IfModule mod_expires.c>
<FilesMatch "\.(jpe?g|png|gif|js|css)">
ExpiresActive On
ExpiresDefault "access plus 7 day"
FileETag None
</FilesMatch>
</IfModule>
我的问题是如何形成FilesMatch正则表达式否定断言以获得除图像、JavaScript 和 CSS 之外的所有内容的结果无缓存。下面不起作用。
# DISABLE ALL CACHING EXCEPT IMAGES,JAVASCRIPT AND CSS
<FilesMatch "\.?!(jpe?g|png|gif|js|css)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Note "CACHING IS DISABLED"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
</FilesMatch>