摘自httpd.conf
<VirtualHost *:80>
部分(目标:为所有 JavaScript文件设置Cache-Control
):
<LocationMatch "\.js"> Header set Cache-Control "max-age=290304000, public" </LocationMatch>
.htaccess
(Symfony PHP框架的一部分):
Options +FollowSymLinks +ExecCGI <IfModule mod_rewrite.c> RewriteEngine On # we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f # no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L] </IfModule>
现在,我用两个指向相同资源的不同URL来检查Cache-Control
标头:
/index.php/pt_BR/home_page.js
: Cache-Control
设置如上所述
/pt_BR/home_page.js
: Cache-Control
与其他值
现在,为什么Cache-Control
头没有设置为/pt_BR/home_page.js
?
请注意, 没有涉及的查询string, 并且在重写之前和之后匹配<LocationMatch "\.js">
。
http://httpd.apache.org/docs/current/sections.html#merging
现在需要出头,我希望以后有更多的时间来解释一下这个问题。