元标记中的错误值

Jos*_*los 16 html5 meta-tags

当我从w3c验证器将html5验证器传递到我的网站时,我遇到了问题.错误是下一个:

Bad value Content-Script-Type for attribute http-equiv on element meta
<meta http-equiv="Content-Script-Type" content="text/javascript" >

Bad value expires for attribute http-equiv on element meta
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" >

Bad value pragma for attribute http-equiv on element meta
<meta http-equiv="pragma" content="no-cache" >

Bad value Cache-Control for attribute http-equiv on element meta.
<meta http-equiv="Cache-Control" content="no-cache" >
Run Code Online (Sandbox Code Playgroud)

传递html5验证器的元标记的正确值是什么?

ews*_*001 7

对于HTML5,您可以在标头中使用缓存清单文件.这是如何使用的示例:http: //www.w3.org/TR/html5/browsers.html#manifests

此外,您不强制使用此缓存:

<meta http-equiv="expires" content="0">
Run Code Online (Sandbox Code Playgroud)

这是一个关于如何使用缓存清单文件的好教程:https: //www.html5rocks.com/en/tutorials/appcache/beginner/#toc-manifest-file-creating

  • html5中不允许expires meta (6认同)

CoR*_*CoR 7

接受的答案是错的!是一个很好的答案.

引用Alohci:

将缓存指令放入元标记并不是一个好主意,因为虽然浏览器可能会读取它们,但代理却不会.因此,它们无效,您应该将缓存指令作为真正的HTTP标头发送.

附录:对于Apache和.htaccess,您可以使用

<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault value      or
ExpiresByType text/css  "access plus 1 month"
...
</IfModule>
Run Code Online (Sandbox Code Playgroud)

PHP有header_sent()和header()函数.

function header_no_cache () {
    \header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
    \header('Pragma: no-cache'); // HTTP 1.0.
    \header('Expires: 0'); // Proxies.
}
Run Code Online (Sandbox Code Playgroud)

要点是缓存说明应该在标题中.不在html文件中.