vhost 配置禁用所有文件的缓存

vhost config to disable caching of all files

这个语法对我的虚拟主机来说正确吗?我不确定这是 all 文件的正确正则表达式。

<filesMatch "\.*">
  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 Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  </ifModule>
</filesMatch>

匹配所有文件的正确表达式是

<filesMatch ".*">

或者

<filesMatch "^.*$">

docs中写着:

The <FilesMatch> directive limits the scope of the enclosed directives by filename, just as the <Files> directive does. However, it accepts a regular expression.

\.* 正则表达式接受类似于 ...... 的字符串,因为 . 在模式中被转义了。

只是示例 (<FilesMatch "\.(gif|jpe?g|png)$">) 具有误导性,因为它仅匹配以 .gif.jpgpngjpeg 结尾的文件].