简体   繁体   English

网站提供的是javascript文件的旧/折旧版本,而不是更新的版本

[英]Website serves the old/depreciated version of javascript file instead of the updated one

EDIT: Would my current meta tags be causing the caching issue? 编辑:我当前的meta标签会导致缓存问题吗?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/homepage.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  

I have a website uploaded to the webhost iPower. 我有一个网站上传到webhost iPower。 My HTML pages link an external javascript file(called AppLogic.js). 我的HTML页面链接了一个外部javascript文件(称为AppLogic.js)。 I find when I upload a new version of AppLogic.js to the webhost that the older versions(previously uploaded versions) are served from the server instead of my latest AppLogic.js upload. 当我将新版本的AppLogic.js上传到Web主机时,我发现从服务器提供了较旧的版本(以前上传的版本),而不是我最新的AppLogic.js上传。 This happens for about 5mins(sometimes even longer) after I upload a new version of AppLogic.js, after that period of time it then begins serving the correct AppLogic.js file(latest one). 在我上传新版本的AppLogic.js之后,这种情况发生了大约5分钟(有时甚至更长),在这段时间之后,它开始提供正确的AppLogic.js文件(最新)。

Do you know why this is happening & how I can stop this? 您知道为什么会这样吗?我该如何阻止呢?

I have a feeling that javascript files are cached in IE, Firefox & that they are not downloading the new file everytime. 我觉得javascript文件已在IE,Firefox中缓存,并且它们不会每次都下载新文件。 I am trying to fix bugs that only occur on the actual webpages served from the webhost (the bugs aren't occuring locally) which means I am constantly tweaking my AppLogic.js file then uploading it to the webserver to see if the change fixed a bug. 我正在尝试修复仅在通过网络托管服务的实际网页上发生的错误(这些错误不在本地发生),这意味着我一直在调整我的AppLogic.js文件,然后将其上传到网络服务器以查看更改是否已解决错误。 Its slow & annoying without this bloody caching of .js files but with this issue its just god damn stopping me from fixing bugs! 没有.js文件的这种高速缓存,它的速度慢而令人讨厌,但是由于这个问题,它真该死,阻止我修复错误!

Any advice on what exactly goes wrong & how to fix it would be extremely helpful 关于到底出了什么问题以及如何解决的任何建议都将非常有帮助

All the following things I have tried but don't stop myself getting the wrong .js file: 我尝试了以下所有操作,但不要阻止自己获取错误的.js文件:
- I have tried pressing CTRL, SHIFT & DELETE in firefox, then deleting all the history & caches -我尝试在Firefox中按CTRL,SHIFT和DELETE,然后删除所有历史记录和缓存
- Pressing CTRL 12 in IE to open the Developer tools, then selecting cache then selecting always load from server, delete cache, delete domain cookies & all the other ones. -在IE中按CTRL 12打开开发人员工具,然后选择缓存,然后选择始终从服务器加载,删除缓存,删除域cookie和所有其他cookie。 This only works sometimes which is dang frustrating. 这仅在有时令人沮丧的情况下有效。
- Use the program CCleaner to remove all my cookies & other IE cached data. -使用CCleaner程序删除我所有的cookie和其他IE缓存的数据。 Sometimes works - Restarting my whole laptop. 有时可行-重新启动我的整个笔记本电脑。 works alot but is ridiculously time consuming 工作很多,但是很浪费时间

You could alter the way you request the JS file, by adding AppLogic.js?123456789 (where the numbers are time). 您可以通过添加AppLogic.js?123456789 (其中数字是时间)来更改请求JS文件的方式。 That way, you force the browser to load the new files at all times! 这样,您可以强制浏览器始终加载新文件!

You can also add the following in ur .htaccess 您还可以在ur .htaccess中添加以下内容

<FilesMatch "AppLogic.js$">
Header unset Cache-Control
Header unset Expires
Header unset Last-Modified
FileETag None
Header unset Pragma
</FilesMatch>

It wont cache the file for the users ...you could try to add that for a period of time then remove it because you don't want to always serve the file ... we want some CACHE ;) 它不会为用户缓存文件...您可以尝试将其添加一段时间,然后将其删除,因为您不想一直提供文件...我们需要一些CACHE;)

SiteSafeNL solution works great , try to declare a global variable version and then it get changed on each website update AppLogic.js?v=1.0.0 then on update AppLogic.js?v=1.0.1 etc ... SiteSafeNL解决方案效果很好,请尝试声明一个全局变量版本,然后在每个网站更新AppLogic.js?v = 1.0.0上进行更改,然后在更新AppLogic.js?v = 1.0.1等上进行更改...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM