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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
    • ¥15 关于arduino编程toCharArray()函数的使用
    • ¥100 vc++混合CEF采用CLR方式编译报错
    • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
    • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
    • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
    • ¥50 如何openEuler 22.03上安装配置drbd
    • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
    • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
    • ¥15 Windows11, backspace, enter, space键失灵