Client/CDN caching of gzipped files #5

Merged
merged 4 commits into from Jul 21, 2011

Conversation

Projects
None yet
2 participants
Contributor

dfellis commented Jul 19, 2011

We're planning on using gzippo in our start-up, but we needed it to respond to modification checks so we don't negate the gain from compressing the files by requiring them to be downloaded by the client on every request, so I've added two related changes to gzippo:

  1. The maxAge value is used to set the expiration date ('Expires') of the file (which also requires the current server's date ['Date'] to be sent so the browser can then re-extract the maxAge value).
  2. The mtime value is used to set 'Last-Modified' for the file, which is used by a client with a cached copy to query if a new version exists ('If-Modified-Since'). At this point the server either responds with the new version, or returns '304' stating that the client has the newest revision.

There's also a test for the new code and it passes, and I tried to match your programming style, so hopefully you'll accept these changes. :)

dfellis added some commits Jul 18, 2011

@dfellis dfellis Added the following to gzippo: 1) Add Date, Last-Modified, and Expire…
…s headers so client-side caching works on gzipped files. 2) Add 304 HTTP Header response if client requests confirmation that current cached version is most up-to-date.
e717fa3
@dfellis dfellis Added the proper response headers for the 304 path and removed the 'c…
…hattiness' with the console.log code accidentally left in.
621e73a
@dfellis dfellis Working on the test. Still not fully functional (even though I've alr…
…eady tested this in the 'real world' with Express and Firefox.
e6ecba3
@dfellis dfellis I discovered a bug in my code writing the test. I had the comparison …
…backwards (>= instead of <= as it should have been) and that's why the test was failing. I'm converted to TDD.
f0a8c1e

@tomgco tomgco merged commit f0a8c1e into tomgco:master Jul 21, 2011

Owner

tomgco commented Jul 21, 2011

Thanks for the contribution! I have made some minor adjustments and just need to do some further testing before I deploy gzippo 0.0.4

Contributor

dfellis commented Jul 21, 2011

Sounds good. I like the changes I see so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment