node.js - Express.js Node Framework - Not caching -


my node.js app uses express , app has route sends json file tweet data. want cache 20 seconds. but, whenever hit refresh in browser (chrome or firefox) new data (even if every second). note data change more every 20 seconds, still want 20 second cache.

here route.

app.get('/tweet-stats.json', function(req, res) {     res.set('cache-control', 'public, max-age=20');     res.set('expires', new date(date.now() + 20000));     res.set('last-modified', new date(date.now()));     res.set('content-type', 'application/json');     res.send(publictweetstatus()); }); 

here request , response headers firefox (firebug):

response headers   http/1.1 200 ok   x-powered-by: express   cache-control: public, max-age=20   expires: fri may 10 2013 06:52:11 gmt+0000 (utc)   last-modified: fri may 10 2013 06:51:51 gmt+0000 (utc)   content-type: application/json   content-length: 209   connection: keep-alive    request headers   /tweet-stats.json http/1.1   host: mydevelopmenturl.com   user-agent: mozilla/5.0 (x11; ubuntu; linux x86_64; rv:20.0) gecko/20100101 firefox/20.0   accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8   accept-language: en-us,en;q=0.5   accept-encoding: gzip, deflate   connection: keep-alive   

how can make browsers cache 20 seconds before checking server again?

update

so, tried robertklep's suggestion , worked in browsers/oss , not others:

ubuntu chrome - no cache!!!!!!!!!!!!
ubuntu firefox - no cache!!!!!!!!!!!!!!!
windows 7 - chrome - cache
windows 7 - firefox - cache
windows 7 - ie 9 - cache
windows 7 - opera - no cache!!!!!!!!!!!!!!!!!
ios safari - cache
mac osx - safari - cache
mac osx - chrome - cache
mac osx - firefox - cache

why differences?


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -