lloyd / connect-etagify Goto Github PK
View Code? Open in Web Editor NEWetagify is connect middleware to add ETag headers to cachable but non-static content.
etagify is connect middleware to add ETag headers to cachable but non-static content.
I don't know if my nginx config or CloudFlare is contributing to this, but I get a strange set of headers instead of an ETag header. Using node v0.8.21 and Express 3.1.0.
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Mon, 04 Mar 2013 05:13:06 GMT
Content-Type: application/json; charset=utf-8
0: E
1: T
2: a
3: g
X-Powered-By: Express
Cache-Control: private
...
Hi!
I'm trying to use your package but when using with express 3.4.x it is throwing an error:
TypeError: Object #<ServerResponse> has no method 'etagify' // res.etagify();
$ curl -i http://localhost:5000/
HTTP/1.1 200 OK
X-Powered-By: Gerbils
Cache-Control: public, max-age=3600
Content-Type: text/html; charset=utf-8
Content-Length: 19
Connection: keep-alive
Well that's weird.
$ curl -i http://localhost:5000/
HTTP/1.1 200 OK
X-Powered-By: Gerbils
ETag: "2657ab1143a8795c9ffaec18a56f1f0c"
Cache-Control: public, max-age=3600
Content-Type: text/html; charset=utf-8
Content-Length: 19
Connection: keep-alive
Well that's weird.
doh! ETags can haz HTTP 1.1, and not HTTP 1.0 (that'd be Last-Modified).
Or does it grow indefinitely ?
I'm pretty sure you're supposed to build the lookup key from the request headers specified in the Vary response header. So if the response indicated Vary: Accept-Encoding, Accept-Language
you wouldn't actually store [ 'Accept-Encoding', 'Accept-Language' ]
in your data structure, I think you're supposed to store the tuple of [req.path, "gzip,deflate,sdch", "en-US,en;q=0.8"]
(assuming Chrome user agent used in request). And you probably need to handle Vary: *
specially.
Ideally though, as mentioned in issue #1, you'd just buffer the content and calculate the ETag directly, in which case the Vary header should be irrelevant since you're not actually acting as a cache. (i.e., if issue #1 is resolved by calculating ETag every single time, this issue becomes invalid.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.