Reputation: 33960
function sendData(response, code, data, mime) {
response.writeHead(code, {
'Content-Length': Buffer.byteLength(data, 'binary'),
'Content-Type': mime,
'Cache-Control': 'max-age=60'
})
response.write(data, 'binary')
response.end()
}
This is my code, I am trying to cache everything for one minute, it is quite straightforward, but each time I click reload in the browser, all files are downloaded again. What is wrong with it?
Upvotes: 0
Views: 2188
Reputation: 29083
Cache-Control headers are a recommendation to the browser but they are allowed to call your server again before the cache expires - which they will do when the user presses the refresh button.
Upvotes: 1