相关疑难解决方法(0)

缓存破坏与创建反应应用程序

当我更新我的网站时,运行npm run build并将新文件上传到服务器我仍在查看我的网站的旧版本.我的项目的回购是 https://github.com/Alfrex92/serverlessapps

没有React,我可以看到我的网站的新版本缓存破坏.我这样做:

上一个文件

<link rel="stylesheet" href="/css/styles.css">
Run Code Online (Sandbox Code Playgroud)

新文件

<link rel="stylesheet" href="/css/styles.css?abcde">
Run Code Online (Sandbox Code Playgroud)

我怎么能做这样的事情或用create react app实现缓存清除?

在创建的github中有许多线程对此做出反应,但没有人有正确/简单的答案.

caching reactjs react-redux create-react-app

36
推荐指数
3
解决办法
3万
查看次数

如何在ASP.NET核心rc2中禁用浏览器缓存?

我尝试过这个中间件,但浏览器仍在保存文件.

我希望用户将始终获得js和css文件的最新版本.

public void Configure(IApplicationBuilder app)
{
    app.UseSession();
    app.UseDefaultFiles();
    app.UseStaticFiles(new StaticFileOptions
    {
        OnPrepareResponse = context =>
            context.Context.Response.Headers.Add("Cache-Control", "no-cache")
    });
}
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-core-mvc

23
推荐指数
3
解决办法
2万
查看次数

不会为 index.html 调用 StaticFileOptions.OnPrepareResponse

我目前正在尝试index.html使用 .NET Core 2.2 后端为我的 Angular SPA禁用缓存。

我根据这个答案通过OnPrepareResponse为我的StaticFileOptions.

但是Cache-Control标头永远不会被发送。当我在 OnPrepareResponse 操作中设置断点时,我会为每个文件中断,除了 index.html

我在这里缺少什么?我怎样才能真正控制index.html文件的缓存?

在此处输入图片说明

// I've changed nothing else in the default ASP.NET Core/Angular template
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    // ...

    var staticFileOptions = new StaticFileOptions
    {
        OnPrepareResponse = context =>
        {
            // Breakpoint for next line hits for following files
            // 1: styles.61d14a95058dbe9da495.css
            // 2: runtime.a66f828dca56eeb90e02.js
            // 3: polyfills.7a0e6866a34e280f49e7.js
            // 4: main.d9791b5a6df420d81994.js
            // 5: …
Run Code Online (Sandbox Code Playgroud)

c# node.js typescript asp.net-core angular

5
推荐指数
2
解决办法
2080
查看次数