Search Results for

    Show / Hide Table of Contents
    View Source

    Class UmbracoBackOfficeCacheHeadersMiddleware

    Sets the default Cache-Control response header on requests served from the cache-busted BackOffice assets path (/umbraco/backoffice/<hash>/...).

    Inheritance
    object
    Namespace: Umbraco.Cms.Web.Common.Middleware
    Assembly: Umbraco.Web.Common.dll
    Syntax
    public class UmbracoBackOfficeCacheHeadersMiddleware
    Remarks

    The path prefix contains a deployment-wide hash derived from the Umbraco version (see BackOfficeCacheBustHash). Because the URL itself changes whenever the version changes, all responses served under that prefix are safe to mark as immutable with a long max-age, regardless of whether the on-disk filename contains a content hash.

    In debug mode the underlying built assets may change while the app is running (typically from a developer rebuilding the backoffice without restarting the host). The header is therefore set to no-cache, which still allows the browser to store the response but forces an If-None-Match revalidation on the next request — yielding fast 304s when nothing has changed and full 200s when the file on disk has been rebuilt. no-store would force a full re-download on every request, which is unnecessary.

    This middleware is non-destructive to consumer customisation:

    • The header is only set when no Cache-Control value is already present on the response, so synchronous overrides written upstream (including StaticFileOptions.OnPrepareResponse) take precedence.
    • The header is set via HttpResponse.OnStarting; consumer callbacks registered later in the pipeline fire first (LIFO) and can therefore override the default.
    • Non-2xx responses (e.g. 404) are not marked as immutable to avoid long-lived caching of error responses.

    Must run before UseUmbracoBackOfficeRewrites(IApplicationBuilder) so the original request path (still containing the cache-bust hash) can be matched.

    Constructors

    View Source

    UmbracoBackOfficeCacheHeadersMiddleware(IBackOfficePathGenerator, IHostingEnvironment)

    Declaration
    public UmbracoBackOfficeCacheHeadersMiddleware(IBackOfficePathGenerator backOfficePathGenerator, IHostingEnvironment hostingEnvironment)
    Parameters
    Type Name Description
    IBackOfficePathGenerator backOfficePathGenerator
    IHostingEnvironment hostingEnvironment

    Methods

    View Source

    InvokeAsync(HttpContext, RequestDelegate)

    Declaration
    public Task InvokeAsync(HttpContext context, RequestDelegate next)
    Parameters
    Type Name Description
    HttpContext context
    RequestDelegate next
    Returns
    Type Description
    Task
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX