html - "Bad value expires for attribute http-equiv on element meta"

标签 html meta w3c-validation http-equiv

好吧,我一直在使用错误的代码,因为我不知道现在多久了 - 看起来

<meta http-equiv="expires" content="0">

错误的是下列正确的

<meta http-equiv="expires" content="mon, 27 sep 2010 14:30:00 GMT">

所以我的问题是,如果他们希望我像上面那样放置日期格式,我如何仍然让它成为 0 以及如何在没有 PHP/JavaScript 的情况下生成它?把它放在日期格式似乎很愚蠢。

最佳答案

你是not allowed在 HTML5 中使用 expires pragma 指令,因为它是 not defined in the HTML5 spec也不registered在维基页面上 PragmaExtensions .

相反,您应该使用相应的 HTTP header 。

根据 RFC 4229 , Expires header 字段在 RFC 2616 中定义, 它的定义非常清楚格式:

The format is an absolute date and time as defined by HTTP-date in section 3.3.1; it MUST be in RFC 1123 date format […]

请注意,它还说明了 0 值:

HTTP/1.1 clients and caches MUST treat other invalid date formats, especially including the value "0", as in the past (i.e., "already expired").

关于你应该做什么:

To mark a response as "already expired," an origin server sends an Expires date that is equal to the Date header value.

关于html - "Bad value expires for attribute http-equiv on element meta",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24773706/

相关文章:

javascript - 如何阻止 DOM 更改立即恢复?

html - CSS/LESS更改多选中所选选项的背景颜色

php - WordPress 更新元不工作

html - Angular 中的动态 CSP(内容安全策略)connect-src

html - 在经过验证的 HTML5 中使用 aria-sort

HTML Head 元素未在 w3.org 验证器上正确注册?

html - 错误 : Element input with attribute type whose value is button must have non-empty attribute value

javascript - 如何在着陆页图形上添加鼠标悬停图像

javascript - 如何打开 POST 生成的 CSV 文件

php - 从 WordPress 中的分类法获取自定义字段值