Table of Contents

Class DynamicCacheBusting

Namespace
Cuemon.AspNetCore.Configuration
Assembly
Cuemon.AspNetCore.dll

Provides cache-busting capabilities on a duration based interval. This class cannot be inherited.

public sealed class DynamicCacheBusting : CacheBusting, ICacheBusting, IConfigurable<DynamicCacheBustingOptions>
Inheritance
DynamicCacheBusting
Implements

Examples

The following example demonstrates how to use DynamicCacheBusting to resolve versioned static resource URLs at runtime.

using System;
using Cuemon;
using Cuemon.AspNetCore.Configuration;
using Microsoft.Extensions.Options;

namespace MyApp.Examples;

public class DynamicCacheBustingExample
{
    public void Demonstrate()
    {
        var options = Options.Create(new DynamicCacheBustingOptions
        {
            PreferredLength = 8,
            PreferredCharacters = Alphanumeric.LettersAndNumbers,
            TimeToLive = TimeSpan.FromHours(12)
        });

        var cacheBusting = new DynamicCacheBusting(options);

        // Version is regenerated when the configured TimeToLive has elapsed.
        string version = cacheBusting.Version;
        Console.WriteLine(version);
    }
}

Constructors

DynamicCacheBusting(IOptions<DynamicCacheBustingOptions>)

Initializes a new instance of the DynamicCacheBusting class.

public DynamicCacheBusting(IOptions<DynamicCacheBustingOptions> setup)

Parameters

setup IOptions<DynamicCacheBustingOptions>

The DynamicCacheBustingOptions which need to be configured.

Properties

Options

Gets the configured options of this instance.

public DynamicCacheBustingOptions Options { get; }

Property Value

DynamicCacheBustingOptions

The configured options of this instance.

UtcChanged

Gets the UTC timestamp from when the Version was last changed.

public DateTime UtcChanged { get; }

Property Value

DateTime

The UTC timestamp from when the Version was last changed.

Version

Gets the version to be a part of the link you need cache-busting compatible.

public override string Version { get; }

Property Value

string

The version to be a part of the link you need cache-busting compatible.

See Also