Screpy SEO platform logo New Screpy is coming πŸŽ‰

Use Efficient Cache Policy with Static Assets

Caching users' site experiences and providing them with this recorded data on their next visit will increase the loading speed of the page.

Reviewed by Screpy Editorial Team

If static resources in the web page cannot perform this caching, in other words, if they are not cached, Google Lighthouse scans and flags them. Like in the image below:

Efficient Cache Policy with Static Assets

In order for the Lighthouse system to accept a page as cacheable, several different conditions must be met. The following conditions must all be met at the same time:

  1. The resource must be in one of the formats such as font, image, media file, script, or stylesheet.
  2. The resource must have an HTTP status code of 200, 203, or 206.
  3. The resource must not have a no-cache policy. Because if such a situation occurs, the necessary conditions cannot be met.

The Google Lighthouse system tells you that an audit has failed and the page in question needs to be fixed, using 3 columns:

  1. URL: The URL associated with the cacheable resource search is given to the user. In this way, the user easily navigates to the area in question.
  2. Cache TTL: The user gets detailed information about the cache duration on the page in question.
  3. Size: Size of data saved by users is written.

How to pass the audit? – Caching static resources using HTTP caching

You need to make your server return the Cache-Control HTTP response header. Here is an example:

Cache-Control: max-age=31536000

The max-age value you see above means: How long should the browser cache the resource in question? This value is the calculated version of this time in seconds. Generally, the value 31536000 is preferred for this. This number of seconds is the number of seconds in a year (24 (hours) x 365 (days)).

If the basic properties of the resource change, mean that the user changes his or her browsing habits, you can use no-cache to cancel the previously saved cache data. In this case, although the browser continues to cache the file marked as no-cache, the control through the server cancels it.

Important Tip: Remember, high cache duration does not always provide the best result. This may prevent necessary improvements in website navigation. Therefore, determining the cache time according to your visitor profile is something you have to do.

There are different methods of caching and they also need to be customized. You can also browse our other related content.

Using Chrome DevTools to verify cached responses

If you want to check what is in the cache files, use Chrome DevTools and open the Network tab from there.

  1. You can then open DevTool by pressing Control + Shift + J (or Command + Option + J on Mac).
  2. Click on the Network tab.

For example, below you see a report about size in the relevant column in Chrome DevTools.

Efficient Cache Policy with Static Assets

Chrome pulls the most requested results in memory cache to provide fast service. When the browser is closed, it deletes this data. To examine whether a resource has the cache-control head properly, the HTTP header data must be checked:

  1. Click on the URL of the relevant page. This URL is located under the name in the Request table.
  2. Then click on the tab that says Headers.

Efficient Cache Policy with Static Assets cache control

Related tasks

Solve the errors logged to the console

If there are error warnings about your website within the console offered by the browser, you need to follow a few basic steps to resolve them.

Tuesday, December 22, 2020

Title Tags Not Found

Are you encountering the title meta tag not found the issue? You can solve it right away! Here are the causes and importance of the problem in detail.

Sunday, December 20, 2020

Robots.txt Not Found

If you are encountering the Robots.txt not found error, you can create your file immediately by paying attention to the steps below. Discover the details now!

Sunday, December 20, 2020

Not Crawlable Pages

Have the same problem with crawlability issues? Let’s see what you can do for your website to be indexed. Here are the ways and solutions!

Sunday, December 20, 2020

Meta Description Not Found

Are you getting a meta description not found a warning about your web page? Let's figure it out! Why is meta description important, how to pass the audit? Examine!

Sunday, December 20, 2020