在apache2中设置适当的过期标题

我在Ubuntu上运行apache2。 我想像这样设置到期标题。

ExpiresActive On <FilesMatch "\.(ico|gif|jpe?g|png|js|css)$"> ExpiresDefault "access plus 1 year" </FilesMatch> 

我深信,它会caching一个像www.example.com/images/a.gif一年的url。

我的问题是什么关于这样的url。 www.example.com/javascripts/all.js?123456。 假设上面的url被caching了。 现在,如果我更改的url为www.example.com/javascripts/all.js?abcdef将浏览器请求新的js文件?

基本上我试图findcaching浏览器考虑完整的url,包括问号后的数据。

另外我目前的虚拟主机configuration是这样的

 <VirtualHost xx.xx.xx.xx:80> ServerName xxxx ServerAlias xxxxx DocumentRoot /home/xxx/current/public <Directory "/home/xxxx/current/public"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <Location /> # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png)$ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </Location> </VirtualHost> 

我假设我可以在标签开始之前放置ExpiresActive On和其他声明。

没关系。 根据你的configuration,all.js?123456会请求all.js的新版本。 您也可以将ExpiresActiveOn放入虚拟主机或目录中。