【发布时间】:2009-05-29 04:17:59
【问题描述】:
当我通过 Privoxy 检查我的浏览器从一个站点下载的内容时,似乎构成页面的所有元素(CSS、JS、图标等)每次都重新下载,即。浏览器不会缓存它们(抱歉,新用途不允许包含 URL):
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>My Site</TITLE>
<meta name="keywords" lang="fr" content="whatever">
<meta name="Description" lang="fr" content="whatever">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Category" content="Internet">
<meta name="revisit-after" content="2 days">
<meta name="author" content="webmaster@example.com">
<meta name="identifier-URL" content="http://www.example.com">
<meta name="robots" content="index, follow">
<meta name="classification" content="Internet">
<meta name="distribution" content="global">
<meta name="geography" content="Paris">
<meta name='language' content='fr'><meta http-equiv='content-language' content='fr'><meta name='rating' content='General'>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="alternate" type="application/rss+xml" title="My RSS" href="http://www.example.com/rss.php" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="icon" href="animated_favicon1.gif" type="image/gif">
<link rel="stylesheet" href="miseenforme.css" type="text/css">
<link rel="stylesheet" href="css/screen2009.css" type="text/css">
<!--[if lte IE 6]>
<link rel="stylesheet" href="css/screen2009-ie6.css" type="text/css">
<![endif]-->
<style type="text/css">@import url(jscalendar-1.0/calendar-blue.css);</style>
<script type="text/javascript" src="jscalendar-1.0/calendar.js"></script>
<script type="text/javascript" src="jscalendar-1.0/lang/calendar-fr.js"></script>
<script type="text/javascript" src="jscalendar-1.0/calendar-setup.js"></script>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="jquery.autogrow.js"></script>
<script type="text/javascript" src="fonctionsjs.js?maj=v1"></script>
</head>
事实上,我在这个 HTML 标头中没有看到任何与缓存相关的说明。
有人可以确认浏览器(IE、Firefox、Chrome)不会缓存任何内容,除非在 HTML 标头中被告知?
我们是否需要配置浏览器来强制它们缓存元素?
谢谢。
【问题讨论】:
-
我希望浏览器尊重 HTTP 标头,但在您的情况下未指定缓存行为,因此您应该检查这些浏览器(或者可能是 http 协议)的默认行为。跨度>
-
标题中的 "elements" 具有误导性,它意味着别的东西 - 建议您改成“resources”吧?
-
其他寻求帮助的人可能希望查看他在回复中发布的其他信息:stackoverflow.com/questions/921630/are-elements-cached-or-not/…
标签: html performance caching