Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 18, 2022 01:21 pm GMT

Serve Static Assets With An Efficient Cache Policy

If you've ever run a Google Lighthouse analysis or pagespeed of your website, you've probably encountered an error like "Serve static assets with an efficient cache policy" or "Leverage browser caching".

Image description

What's a static asset?
Static assets are files or resources send to the user that the server does not change. Resources that do not change between different requests. Images, fonts, CSS, or JS files are good candidates to be considered as static assets in your website.

What is a cache policy ?
Image description

Why we need cache policy ?

When a browser requests a file, the server providing the file can tell the browser how long it should cache the file. If the user re-requests the file (by revisiting your site) in this duration, the browser can use the local copy instead of re-downloading it. In this way, HTTP caching helps load your pages faster for returning users , also reduce the traffic on your servers

A server tells the browser about caching a file through a cache-control header, It looks like this:

Cache-Control: public, max-age=31536000


Original Link: https://dev.to/ahmedab84879559/serve-static-assets-with-an-efficient-cache-policy-4f51

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To