Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pass in gzippo's maxAge when deferring to connect.static.send for non-gzippable content #8

Merged
merged 1 commit into from

2 participants

@mdrcode

Currently, files which fail to match contentTypeMatch are served with the underlying connect.static.send which defaults to maxAge=0 (i.e. they are immediately stale). This has the undesirable consequence that any image files served by gZippo are thus never cached by the browser (the browser does reuse the file, but it always queries the server with an If-Modified-Since).

With this change, we use gZippo's maxAge value when 'pass'ing to connect.

This brings up an interesting issue of whether gZippo is intended solely for gzippable content ... or whether it should try to replicate normal 'static' middleware behavior for other content types (e.g. images). It might be interesting to contemplate using the same 'options' format for gZippo as the underlying connect middleware for maximum overlap.

@mdrcode mdrcode Currently, files which fail to match contentTypeMatch are served with…
… the underlying connect.static.send which defaults to maxAge=0 (i.e. they are immediately stale). This has the undesirable consequence that any image files served by gZippo are thus never cached by the browser (the browser does reuse the file, but it always queries the server with an If-Modified-Since).


With this change, we use gZippo's maxAge value when 'pass'ing to connect.

This brings up an interesting issue of whether gZippo is intended solely for gzippable content ... or whether it should try to replicate normal 'static' middleware behavior for other content types (e.g. images). It might be interesting to contemplate using the same 'options' format for gZippo as the underlying connect middleware for maximum overlap.
db015ca
@tomgco tomgco referenced this pull request from a commit
@tomgco Adding test case to cover Issue #8 383a8c1
@tomgco tomgco merged commit db015ca into tomgco:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2011
  1. @mdrcode

    Currently, files which fail to match contentTypeMatch are served with…

    mdrcode authored
    … the underlying connect.static.send which defaults to maxAge=0 (i.e. they are immediately stale). This has the undesirable consequence that any image files served by gZippo are thus never cached by the browser (the browser does reuse the file, but it always queries the server with an If-Modified-Since).
    
    
    With this change, we use gZippo's maxAge value when 'pass'ing to connect.
    
    This brings up an interesting issue of whether gZippo is intended solely for gzippable content ... or whether it should try to replicate normal 'static' middleware behavior for other content types (e.g. images). It might be interesting to contemplate using the same 'options' format for gZippo as the underlying connect middleware for maximum overlap.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  lib/staticGzip.js
View
1  lib/staticGzip.js
@@ -97,6 +97,7 @@ exports = module.exports = function staticGzip(dirPath, options){
function pass(name) {
var o = Object.create(options);
o.path = name;
+ o.maxAge = maxAge;
staticSend(req, res, next, o);
}
Something went wrong with that request. Please try again.