简体   繁体   English

ASP.Net 核心缓存

[英]ASP.Net Core caching

I have a .js file that is being statically served in my application.我有一个在我的应用程序中静态提供的 .js 文件。 This file will continue to change through the course of development-这个文件会在开发过程中不断变化——

I had made some changes to the file this morning as I normally do.今天早上我像往常一样对文件进行了一些更改。 Debugging the project, I discovered that the changes in the .js were not reflected- ie the browser was using an older version of the javascript file.调试项目时,我发现 .js 中的更改没有反映 - 即浏览器使用的是旧版本的 javascript 文件。

I have been working on this project for a few weeks and the changes in the .js file have always been reflected in the next debug until today.我已经在这个项目上工作了几个星期,直到今天,.js 文件中的更改一直反映在下一次调试中。 I have tried in both Chrome and Edge.我在 Chrome 和 Edge 中都尝试过。

What gives?是什么赋予了? I'm puzzled about the change in behavior.我对行为的变化感到困惑。 I did receive a Windows update overnight, could it be there's a global setting for browser caching which was previously disabled on my system and was enabled by the update.我确实在一夜之间收到了 Windows 更新,是否有浏览器缓存的全局设置,该设置以前在我的系统上被禁用并通过更新启用。 I am aware of cache busting techniques but in the past, I've always just been able to update the a static .js file and the browser has always used the latest .js file.我知道缓存破坏技术,但在过去,我总是能够更新静态 .js 文件,而浏览器总是使用最新的 .js 文件。

Hopefully someone else might find this helpful.希望其他人可能会发现这有帮助。 I was poking around Visual Studio and in the "play button" next to IIS Express, there is a menu option called "Script Debugging" that I happened upon and was set to disabled.我正在浏览 Visual Studio,在 IIS Express 旁边的“播放按钮”中,有一个名为“脚本调试”的菜单选项,我偶然发现并被设置为禁用。 I enabled the setting and things are back to working as previously.我启用了设置,事情又回到了以前的工作状态。

I was able to confirm that by disabling the setting, Chrome and Edge use a cached version of the script file.我能够通过禁用设置来确认 Chrome 和 Edge 使用脚本文件的缓存版本。

My guess is a Windows update disabled the setting.我的猜测是 Windows 更新禁用了该设置。 Can someone explain how changing this setting in Visual Studio affects caching in browsers?有人可以解释在 Visual Studio 中更改此设置如何影响浏览器中的缓存吗?

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

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