mape / connect-assetmanager

Middleware for Connect (node.js) for handling your static assets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I change cache control headers on responses?

geek-caroline opened this issue · comments

So far as I can tell, there is no way for me to set my own cache-control headers on assets.

I've tried using serveModify, but it looks to me like any settings I put here for 'Cache-Control' or 'Expires' are overwritten by lines 388 / 399:

'Cache-Control': 'public,max-age=' + 31536000,
'Expires': response.expires || (new Date(new Date().getTime()+63113852000)).toUTCString(),

So am I correct in saying I am unable to set a bespoke max-age for an asset?

I don't want my files to have a max-age of a year, I would prefer something closer to an hour as they may well change.

I'm not sure however if I've misunderstood something in the implementation but it appeared to me that others may have used the serveModify method to overwrite the default headers but I do not seem able to?

@geek-caroline I needed this, so i've implemented on my own fork. Now sending the PR to upstream. Cheers!