Question

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" -->

The virtual server config has both SSIETag and SSILastModified set to On for that file

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

It correctly serves the concatenated scripts but is always a full 200 OK in instead of a 304 Not Modified. The Firebug log

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

Is there a hard coded restriction on conditional requests for the INCLUDE filter?

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

EDIT

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

Was it helpful?

Solution

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

OTHER TIPS

When having

SSILastModified on 
XBitHack full

together in configuration file, the setting "SSILastModified On" is a silent misconfiguration, because whether "SSILastModified" is on or not, it does not change any program behavior.

By tracking back to the source code of Apache, we can see the root cause of this misconfiguration is that the semantics enabled by "Xbithack Full" implicitly overwrite the semantics enabled by "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);
}

So one possible solution would be just keep this

Xbithack full
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top