我正在尝试使用INCLUDE
过滤器将一堆javascript文件动态连接到一个文件中。 include.shtml.js
测试脚本是
<!--#include virtual="/static/script2.js" -->
<!--#include virtual="/static/script1.js" -->
虚拟服务器配置为该文件设置SSIETag
和SSILastModified
{/ 1}}
On
它正确地提供了连接脚本,但始终是<VirtualHost *:80>
ServerName test.dkt
ServerAlias test.com
UseCanonicalName Off
ErrorLog logs/test.dkt-error_log
CustomLog logs/test.dkt-access_log combined
LogLevel info
FileEtag All
AddType application/javascript .js
DocumentRoot /var/www/html/test.com
<Directory /var/www/html/test.com>
Options -Indexes
ExpiresActive Off
ExpiresDefault "access plus 1 years"
Header append Cache-Control "public"
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/html/test.com/static>
<FilesMatch "\.shtml\.js$">
SSIETag On
SSILastModified On
Options +Includes
SetOutputFilter INCLUDES
</FilesMatch>
</Directory>
</VirtualHost>
而不是200 OK
。 304 Not Modified
日志
Firebug
对Response Headers
HTTP/1.1 200 OK
Date: Fri, 24 Jan 2014 16:57:12 GMT
Server: Apache/2.2.15 (CentOS)
Last-Modified: Fri, 24 Jan 2014 16:53:32 GMT
Etag: "460bbc-5c-4f0ba32b7447d"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: public
Content-Length: 40
Connection: close
Content-Type: application/javascript
Request Headers
GET /static/include.shtml.js HTTP/1.1
Host: test.dkt
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pt-br,en-us;q=0.9,es;q=0.7,en;q=0.6,zh-tw;q=0.4,ar-sa;q=0.3,ar;q=0.1
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
If-Modified-Since: Fri, 24 Jan 2014 16:53:32 GMT
If-None-Match: "460bbc-5c-4f0ba32b7447d"
Cache-Control: max-age=0
过滤器的条件请求是否存在硬编码限制?
我知道只要任何包含的脚本发生更改,我就应该“触摸”包含脚本。 Apache版本是在Centos 6中运行的2.2
使用@covener answer我使其工作设置文件的组执行权限并添加INCLUDE
指令
答案 0 :(得分:1)
即使您选择了etags,似乎您需要单独启用xbithack以允许生成304(核心中的ap_meets_conditions检查mod_include中引用的no_local_copy标志
http://httpd.apache.org/docs/current/mod/mod_include.html#xbithack
/* When our xbithack value isn't set to full or our platform isn't
* providing group-level protection bits or our group-level bits do not
* have group-execite on, we will set the no_local_copy value to 1 so
* that we will not send 304s.
*/
if ((conf->xbithack != XBITHACK_FULL)
|| !(f->r->finfo.valid & APR_FINFO_GPROT)
|| !(f->r->finfo.protection & APR_GEXECUTE)) {
f->r->no_local_copy = 1;
}
答案 1 :(得分:0)
当有
SSILastModified on
XBitHack full
在配置文件中,设置“SSILastModified On”是一个无提示的错误配置,因为无论“SSILastModified”是否打开,它都不会改变任何程序行为。
回溯到Apache的源代码,我们可以看到这个错误配置的根本原因是“Xbithack Full”启用的语义隐式覆盖了“SSILastModified On”启用的语义。
if (conf->lastmodified > 0) {
... {
ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);}}
else if (((conf->xbithack == XBITHACK_FULL ||
(conf->xbithack == XBITHACK_UNSET &&
DEFAULT_XBITHACK == XBITHACK_FULL))
...)) {
ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
}
所以一种可能的解决方案就是保留这个
Xbithack full