Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for blank page on Safari reload #7

Merged
merged 1 commit into from

2 participants

@jjavery

Often when Safari's reload button is used on a page served by Express, the result is a blank page.

Safari sends Cache-Control: max-age=0 on reload, rather than no-cache like other browsers. Node-fresh considers the cache stale when Cache-Control: no-cache headers are received, but it doesn't do the same for Cache-Control: max-age=0. This commit make the behavior the same in both cases. This updated code has been in heavy use by my team for the last 20 days, and we haven't encountered any problems with it.

http://stackoverflow.com/questions/18811286/nodejs-express-cache-and-304-status-code

http://stackoverflow.com/questions/1046966/whats-the-difference-between-cache-control-max-age-0-and-no-cache

@tj
Owner
tj commented

hmm I've never once seen this behaviour out of safari, weird!

@tj tj merged commit c365eb9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 index.js
View
4 index.js
@@ -33,8 +33,8 @@ function fresh(req, res) {
// unconditional request
if (!modifiedSince && !noneMatch) return false;
- // check for no-cache cache request directive
- if (cc && cc.indexOf('no-cache') !== -1) return false;
+ // check for no-cache or max-age=0 cache request directive
+ if (cc && (cc.indexOf('no-cache') !== -1 || cc.indexOf('max-age=0') !== -1)) return false;
// parse if-none-match
if (noneMatch) noneMatch = noneMatch.split(/ *, */);
Something went wrong with that request. Please try again.