weixin_33691700 2014-06-28 11:37 采纳率: 0%
浏览 24

何时使用Ajax缓存

Please consider below sample with struts 2 jquery plugin, ( but this could be happen with jquery)

In struts 2 jquery plugin set head tag to cache ajax calls:

ajaxcache="true"

The html head is ( do not cache any thing):

<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Pragma" content="No-cache" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Expires" content="0" />

There is also an interceptor which set resonse header as below:

    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control",
            "no-cache, no-store, must-revalidate");
    response.setDateHeader("Expires", 0);

Consider a sample test.jsp file with single js in it

<script type="text/javascript" src="js/grid.js"></script>

The first time the test.jsp is loaded the grid.js is loaded and cached by browser, changing the grid.js will not cause the browser to get updated grid.js file any more !!

Of course I can fix this issue by setting ajaxcache="false"

My question is, if the grid.js is loaded only once and the client do not get newly updated js anymore, then what is the use of ajax caching ?!

Can you suggest a real case which you do not need to update any resource on the client, so client can catch a resource for a long time?!

Or we can use ajax caching in other ways ?!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效