简体   繁体   English

更改不会显示在Google云计算引擎VM上

[英]Changes do not show up on google cloud compute engine VM

When I upload any changes in javascript files to my deployed site on Google cloud compute engine, the changes do not show up right away, if I load the js files in browser. 当我将javascript文件中的所有更改上传到我在Google云计算引擎上已部署的站点时,如果将js文件加载到浏览器中,这些更改都不会立即显示。 The changes are physically there, validated by RDPing to the server. 更改实际上已存在,并通过RDPing验证到服务器。 B

These changes sometime take 6 to 8 hours to show up in browser, and sometimes show up sporadically. 这些更改有时需要6到8个小时才能显示在浏览器中,有时会偶尔显示。 What can I do to ensure that my changed js files take effect immediately on load? 如何确保更改后的js文件在加载后立即生效?

I dont face this problem when I upload on my test server, which is not under cloud. 当我在不在云中的测试服务器上上传时,我没有遇到这个问题。 Happens only on the google cloud server. 仅在Google云服务器上发生。

Try opening your builtin browser debugger (for example right-click on your page, if using Chrome, and click "Inspect"). 尝试打开内置的浏览器调试器(例如,如果使用的是Chrome,请在页面上单击鼠标右键,然后单击“检查”)。 Now select the Network tab. 现在选择网络选项卡。 Now reload. 现在重新加载。 Now look at the sizes of the files. 现在查看文件的大小。 If they are very small, then probably the browser loaded cached copies. 如果它们很小,则可能是浏览器加载了缓存的副本。 You can verify this by checking the "Disable cache" option in the Inspector. 您可以通过检查检查器中的“禁用缓存”选项来验证这一点。

If it works correctly and the file updates right away when you have the browser cache disabled, then you need to investigate with your web server software to see how to cause it to invalidate caches. 如果禁用浏览器缓存后它可以正常工作并且文件立即更新,则需要使用Web服务器软件进行调查,以了解如何使它使缓存无效。 One mechanism you can look into is called "ETags." 您可以研究的一种机制称为“ ETag”。

What worked was invalidating the cloud cache for the file. 起作用的是使文件的云缓存无效。 Lesson learnt: always add version numbers to your js files. 经验教训:始终在您的js文件中添加版本号。

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

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