Copied to clipboard

Flag this post as spam?

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


  • AbsolutelyN 89 posts 437 karma points
    Jul 13, 2022 @ 08:44
    AbsolutelyN
    0

    Custom backoffice section caching templates

    I'm building a large custom backoffice section but when making changing keep running into caching issues. Using umbraco 9.5

    Whilst building its easy to just have the developer tools open and there are no issues. However when changes are published and other people test they often get older cached versions of the templates. Then then have to open developer tools with caching disabled and refresh ... that works but its not practical once real users are using it and a chance needs to be made.

    I've tries to solve it by changing the runtime minification settings - that kinds of works but seems inconsistent, some pages get new versions and other don't.

      "RuntimeMinification": {
        "UseInMemoryCache": false,
        "CacheBuster": "Version",
        "Version": "2.13072022"
      },
    
      "Hosting": {
        "Debug": true
      },
    

    Has anyone got any tips on ensuring latest backoffice pages are rendered when changes are made? Thanks

  • AbsolutelyN 89 posts 437 karma points
    Jul 13, 2022 @ 09:26
    AbsolutelyN
    0

    Possibly found the solution - need to check it works for testers. Setting cachebuster to AppDomain and recycling the process seems to do it.

      "RuntimeMinification": {
        "UseInMemoryCache": true,
        "CacheBuster": "AppDomain",
        "Version": "2.13072022"
      },
    

    Still seems inconsistent ...

  • AbsolutelyN 89 posts 437 karma points
    Jul 13, 2022 @ 14:58
    AbsolutelyN
    100

    This solution seems to work. Manually setting the response headers for any file in the directory /app_plugins/. Obviously best to remove once all backend development complete but when a backend is still developing as people using it is seems to do the job. Could be changed to apply to a specific plugin directory. Hope it helps someone.

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
    
            app.UseStaticFiles(new StaticFileOptions()
            {
    
                OnPrepareResponse = (ctx) =>
                {
                    if (ctx.File.PhysicalPath.Contains(@"\App_Plugins\"))
                    {
                        var headers = ctx.Context.Response.GetTypedHeaders();
                        headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue
                        {
                            Public = true,
                            MaxAge = TimeSpan.FromSeconds(0)
                        };
                    }
                }
            });
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft