阻止在HTML中缓存某些JS文件.(PhoneGap)

Prevent caching of some JS files in HTML. (PhoneGap)

本文关键字:文件 JS PhoneGap HTML 缓存      更新时间:2023-09-26

在一个简化的例子中,我有以下HTML页面(iOS和Android上的PhoneGap应用程序):

<html>
<head>...</head>
<body>
    ...
    <script>
    document.write('../../Documents/data.js?u='+(new Date()).getTime() );
    </script>
    <script src="js/some.js"> </script>
</body>

但这只是一个破解,尽管它似乎有效,但我相信应该有一个更好的解决方案。

您可能会使用应用程序缓存来表示每次都需要通过网络加载date.js。

http://www.html5rocks.com/en/tutorials/appcache/beginner/

此"WorkAround"工作正常。遵循相同的解决方法。。。。如果您希望在需要时"清除缓存",请手动设置版本。

<html>
  <head>...</head>
  <body>
    ...
  <script>
     document.write('../../Documents/data.js?u=001');    //Fixed version
  </script>
<script src="js/some.js"> </script>