You can use it for HTML and Service Worker script.Ĭache-Control: public, max-age=0, must-revalidate ![]() The browser should not store anything about the request when it’s told no-store. This technique is called long-term caching.īut when you prevent re-downloading, how can you then make updates to your website? Maintaining the ability to update the website is why it’s so important to never cache HTML files.Įvery time you visit my site, the browser fetches a fresh copy of the HTML file from the server, and only when there are new script srcs or link hrefs is the browser downloading a new asset from the server. You can achieve the same configuration in WebPack to include a, or - even better - a, in the file name of your assets. This strategy is viable as my assets files have unique identifiers in the file names. In the end, we’ll look into how popular services created in React are serving their web applications.įor a single page application, I’m interested in caching JavaScript, CSS, fonts, and image files indefinitely and preventing caching HTML files and service workers (if you have any). You’re going to find an example of a configuration for Nginx and the code for Node.js running Express. In this post, I’ll focus on explaining how different headers influence the browser cache and how they relate to proxy servers. ![]() ![]() The old spec is mixing with the new: there are numerous settings to configure, and you can find multiple users reporting inconsistent behavior. There are multiple headers available that developers and ops people can use to manipulate cache behavior. Caching headers: A practical guide for frontend developers Michal Zalecki Follow Senior Engineer at □, smart contracts, fan of hackathons, React Wrocław meetup organizer.
0 Comments
Leave a Reply. |