Reputation: 511
I've built a simple page to test the cache-control and I'm getting confused by the results. The page is just
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Website teste</title>
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<div>Hello World</div>
<script>
setTimeout(function () {
window.location.reload()
}, 10000)
</script>
</body>
</html>
If I do a hard-refresh the cache-control is what expected
but the next refresh the cache-control changes to max-age=0
And shouldn't the result be a 304 (Not Modified) instead a 200 (OK)
This sample site is running on VisualStudio (IIS)
Upvotes: 2
Views: 2665
Reputation: 48932
The http-equiv
attribute of the meta
element is defined in the HTML standard. Note that:
The
http-equiv
attribute is an enumerated attribute. The following table lists the keywords defined for this attribute...
cache-control
is not one of the listed values, and thus this directive has no effect.
Your assumption isn't unreasonable, though; in earlier versions of the standard it was suggested that servers could create headers based on this element:
HTTP servers may read the content of the document
<HEAD>
to generate header fields corresponding to any elements defining a value for the attributeHTTP-EQUIV
. NOTE - The method by which the server extracts document meta-information is unspecified and not mandatory.
I have no idea whether any servers actually did this, though.
Finally, note that the Cache-Control
header you're looking at in the developer tools is a request header, not a response header, and thus has nothing to do with any of this. It's something that browsers often add to the request on refresh to make sure they don't get served cached content.
Upvotes: 1