HTTP - Caching (Cache-Control Header)

> (World Wide) Web - (W3|WWW) > (HTTP|HTTPS) - Hypertext Transfer Protocol

1 - Status Code

HTTP status code 304: response coming from the browser cache

2 - How

2.1 - Apache htaccess configuration

If the mod_header is present, Apache can send the caching header.

Example in the root htaccess, max age is in second

# Cache File
<IfModule mod_headers.c>
    # WEEK
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
        Header set Cache-Control "max-age=604800, public"
    </FilesMatch>
 
    # WEEK
    <FilesMatch "\.(js|css|swf)$">
        Header set Cache-Control "max-age=604800"
    </FilesMatch>
</IfModule>
Advertising

3 - Documentation / Reference

  • Caching (rfc7234), R. Fielding, M. Nottingham, J. Reschke. IETF.
web/http/cache.txt ยท Last modified: 2019/02/09 11:22 by gerardnico