有条件的请求,包括不兑现 [英] Conditional request not honored in Includes

查看:94
本文介绍了有条件的请求,包括不兑现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用包含过滤器动态串联一堆javascript文件到一个文件中。在 include.shtml.js 测试脚本

I'm trying to dynamically concatenate a bunch of javascript files into a single file using the INCLUDE filter. The include.shtml.js test script is

<!--#include virtual="/static/script2.js" -->
<!--#include virtual="/static/script1.js" -->

虚拟服务器配置有两个 SSIETag SSILastModified 设置为该文件

<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未修改。在萤火虫日志

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

有没有对条件请求硬codeD限制的包含过滤?

我知道,我应该摸了包括脚本每当有任何附带的脚本的变化。 Apache的版本是在CentOS 6的运行2.2

I'm aware that I should "touch" the including script whenever there is a change in any of the included scripts. The Apache version is 2.2 running in Centos 6

使用 @covener回答我把它设置工作组执行该文件的权限,并添加 XBitHack全指令

Using the @covener answer I made it work setting the group execute permission of the file and adding the XBitHack full directive

推荐答案

即使您已经选择了ETag的,看来你需要单独启用xbithack允许304到核心支票生成(ap_meets_conditions no_local_copy标志mod_include负责引用

Even though you've opted into the etags, it seems you need to separately enable xbithack to allow a 304 to be generated (ap_meets_conditions in the core checks no_local_copy flag referenced in mod_include

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;
}

这篇关于有条件的请求,包括不兑现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆