如何在我的JavaScript文件中加载JSON文件,并确保如果我在用户查看我的网站时更新JSON文件,它将始终使用最新版本,而不是使用缓存版本?在JavaScript中加载json数据文件并避免缓存
说,在我的javascript我打开一个文件,该文件是这样的JSON数据文件:
// Create a <script> tag and set the USGS URL as the source.
var script = document.createElement('script');
// This example uses a local copy of the GeoJSON stored at
// http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp
script.src = 'https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js';
document.getElementsByTagName('head')[0].appendChild(script);
如果远程文件的变化,我怎么能保证它总是加载最新版本的文件,而不是由浏览器缓存?
你是否控制托管javascript文件的服务器? –