Serve static assets with an efficient cache policy

Serve static assets with an efficient cache policy

  • Thread starter Thread starter xenvnVerified member
  • Start date Start date
Serve static assets with an efficient cache policy.webp


HTTP caching can speed up your page load time on repeat visits.
When a browser requests a resource, the server providing the resource can tell the browser how long it should temporarily store or cache the resource. For any subsequent request for that resource, the browser uses its local copy rather than getting it from the network.

How to cache static resources using HTTP caching
Configure your server to return the Cache-Control HTTP response header:
Cache-Control: max-age=31536000
The max-age directive tells the browser how long it should cache the resource in seconds. This example sets the duration to 31536000, which corresponds to 1 year: 60 seconds × 60 minutes × 24 hours × 365 days = 31536000 seconds.
When possible, cache immutable static assets for a long time, such as a year or longer.

Simple way:
Edit the .htaccess file and add the following code:
Code:
You must be logged-in to view.
(1 lines)
Request: Apache Module mod_expires
 
Top