【发布时间】:2017-09-06 15:06:05
【问题描述】:
我正在尝试启用浏览器缓存我的 Web 应用程序的 javascript、css 文件。我使用的文档类型是 JSP。
我看到 manifest.appcache 已弃用,实现缓存的最佳方法是什么,以便浏览器缓存 js、css 文件。
下面是我的代码
<html manifest="../manifest.appcache">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Web app</title>
<link rel="stylesheet" href="<%= contextPath %>/app.css">
</head>
<body>
<script type="text/javascript" src="<%= contextPath %>/app.js"></script>
</body>
</html>
【问题讨论】:
-
您确定路径存在吗?用纯字符串输入路径会得到什么
-
是的,它存在,我删除了@include文件只是为了保持干净,路径是resources/app/app.js,app.css
-
在体内执行
<p><%= contextPath %></p>会得到什么 -
localhost:8080/resources
-
localhost:8080/resources + /app.js 组成
localhost:8080/resources/app.js你说整个路径是resources/app/app.js你缺少/app吗?!
标签: javascript jsp browser browser-cache cache-control