Assets and caching

I was surprised to find that assets are served with a Cache-Control: max-age=0 header, which means that the browser will always revalidate them. Glitch seems to append a timestamp when copying an asset’s URL to the clipboard, shouldn’t it then be safe to give assets a long max-age like 1 year?

1 Like

Thanks for pointing this out, I’ve pushed an update that sets newly uploaded assets to have a max-age of one year. :thumbsup:

3 Likes

I have dis-satisfaction with this feature. When I upload an asset to this site that has the same name as a previously uploaded asset for the convenience of replacing, the original link will be cached and I have to change the link slightly to make it work again. This is annoying and although there is probably a solution to this, it would be nice if there was an option in the query to specify a no-cache tag, or even better, a duration for the cache.

1 Like

Hey @Frank-9976 thanks for the comment. We have some significant changes to the way we handle assets in our backlog; I’ll mention this to the team to make sure it’s considered when we design those changes. Can you clarify for me what you mean by

so I can make sure I’m understanding this properly? Perhaps an example would make it easier for me to understand.

The query is the thing that comes after the ? in the url.
Maybe something like ?maxage=time where time is the time in some amount of unit.
BTW I use your express apps sometimes and that is what it is called iirc. Though maybe I should have said query string instead.

You’re right, that’s what the Express Request property is called - I just wanted to make sure I understood what you meant. To be perfectly clear, you’re talking about using that query string param when you request the asset from the asset store (for example when you include an image in a web page and someone loads the webpage), correct?

Correct. I looked it up upon creating my last reply and I found that this is the name for it. https://en.wikipedia.org/wiki/Query_string