3

how do i cache specific files in html ? i have tried


meta http-equiv="cache-control" content="private" max-age="604800"

but when i click "audit" using google chrome inspect element its giving me

Leverage browser caching (4)
The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers:
some.css
some.js
The following resources are explicitly non-cacheable. Consider making them cacheable if possible:
some.html
some-hosted.html

how do i cache em ?

2 Answers 2

4

Your syntax is invalid.

<meta http-equiv="cache-control" content="max-age=604800;private" />

Mind you this won't work for CSS/JS or anything else that isn't a HTML file. In those cases you need to set real HTTP headers server-side (which is usually done using webserver settings or via dynamic server-side languages like PHP, .Net, Coldfusion, etc...).

Sign up to request clarification or add additional context in comments.

1 Comment

Why did you set it to private?
1

The best way of doing this is to server your files through some kind of server side mechanism that attaches the right cache control headers to the http response.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.