---
description: >-
  To set up an efficient cache policy, follow the instructions below, depending
  on the web server used to serve your static assets:
---

# How to serve static assets with an efficient cache policy?

<figure><img src="https://1456780224-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJWDLal7zQm4jBVPBOwyp%2Fuploads%2F0uPjWMAYy0AMQUe10xg6%2FCaptura%20de%20pantalla%202023-02-21%20a%20la(s)%207.29.19%20a.%C2%A0m..png?alt=media&#x26;token=f4e512e6-535c-4ddb-88ff-146e1dd0dd41" alt=""><figcaption></figcaption></figure>

#### 1) For Apache servers

Copy and paste the below code into your `.htaccess` file.

```
<IfModule mod_expires.c>
  ExpiresActive On

 # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Video
  ExpiresByType video/webm "access plus 1 year"
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"

  # Fonts
  ExpiresByType font/ttf "access plus 1 year"
  ExpiresByType font/otf "access plus 1 year"
  ExpiresByType font/woff "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType application/font-woff "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"

  # Others
  ExpiresByType application/pdf "access plus 1 year"
  ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</IfModule>
```

#### 2) For other servers

Read the following guides to learn how to setup browser caching on other server types:

* [NGINX](https://www.keycdn.com/blog/leverage-browser-caching#cache-control-headers-on-nginx)
* [Microsoft IIS ](https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache)
