Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 510 posts 2082 karma points
    Nov 13, 2023 @ 15:34
    David Armitage
    0

    Umbraco 10-12 app.UseStaticFiles() does nothing

    Hi All,

    I have played around with this most the day. I have seen a few other forum posts talking about how to enable static asset caching.

    app.UseStaticFiles(new StaticFileOptions
                {
                    OnPrepareResponse = ctx =>
                    {
                        const int durationInSeconds = 60 * 60 * 24;
                        ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                            "public,max-age=" + durationInSeconds;
                    }
                });
    

    I have tried everything and it just does not seem to be cachign whatever I do or wherever I put the app.UseStaticFiles

    Has anyone got this working? And can you send me a copy of your startup.cs file so I can compare this with mine.

    As you can see in the screenshot the images are just not flagging up as cached.

    enter image description here

  • Yakov Lebski 594 posts 2350 karma points
    Nov 13, 2023 @ 23:02
    Yakov Lebski
    0

    yes, we didm you can use our package https://www.dyfort.com/products/umbraco-static-files/, I'll try to push code to gihub later

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies