top of page
  • Writer's pictureBrent D. Payne

Serve static assets with an efficient cache policy

The URLs in question could potentially include resource URLs like media or script files that do not contain a specified cache header.

Why is this important?

Network requests can be slow and costly. Large sized responses can require multiple roundtrips and consequently delay processing and incur additional data costs for users.

Caching through server response header informs the browser that subsequent downloads of the asset are unnecessary, thus reducing requests to the server. Therefore, HTTP caching enhances page load times during subsequent visits.

What does the Optimization check?

This check is activated when any internal resource lacks caching, or where caching policy duration is shorter than one year (31536000 seconds).

Resources regarded as 'cacheable' receive a 200 status code, are free from a no-cache directive, and are typically fonts, images, media, scripts, or stylesheets.

How do you resolve this issue?

Implementing the Cache-Control header in your server's response is crucial as it enables caching within the browser. Once activated with appropriate values, the browser will store the file for the specified timeframe. Without it, the file would be fetched repeatedly with each visit.

To add the header, configure your server:

Cache-Control: max-age=31536000

The max-age directive indicates the duration for which the browser should cache the resource, stated in seconds. Setting it to 31536000 seconds equals one year.

Strive to cache as many responses as you can for the maximum duration permitted, including validation tokens to allow efficient revalidation.

Analyze the decision-making diagram to identify an optimal caching policy for specific resources in your application.

Further Reading



bottom of page