How and Where I Learned Design?

When I was studying in college, I started off studying Electronics Engineering and then completed my intern as a Web Designer. After I realised I wasn’t completely passionate about what I wanted to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Browser cache times when using Cloudfront

Earlier last year (2020) I had a problem to solve — cache particular content in Cloudfront for as long as possible (and rely on invalidations when needed), but at the same time cache that content only for an hour on the browser.

The problem lies in the way Cloudfront, or almost any other proxy server for that matter, handles the content — the response from the origin is cached together with all headers. Then when we ask for that content, the proxy replies with the same headers, which obviously includes an old Date header. In addition, the proxy also adds an Age header that shows how old the content has been since it was retrieved from the origin.

That of course is the right thing to do, but when you have sayCache-Control: max-age=3600 and Age: 3900, that means your content has already expired and won’t be cached locally by the client (browser):

This simple function above does everything we needed to simply have this kind of header output:

where Fri, 29 Oct 2021 01:21:19 GMT is the current date and time.
The browser will cache this content for exactly 1 hour and we have some happy engineers :)

The end.

Add a comment

Related posts:

Como o time de UX Writing do will Bank cresceu

De uma pessoa para um time de dez. Foi assim que começou o UX Writing do will Bank. O produto will já estava quase todo desenhado quando cheguei para escrever, sob a ótica da melhor experiência…

Do Certain Medicines Increase Your Dementia Risk?

SHOULD YOU BE CONCERNED ABOUT MEDICINES and your own risk of cognitive impairment (for example, dementia)? There is mounting evidence of a connection between dementia and so-called anticholinergic…

Landed your stories at Multimedia as TikTokers

Sounds like this video platform would save your time! It actually does… And understand how this works? The short-stories platform is a semi-melted cheese sandwich that you’d wish to taste with Warm…