Table of Contents

DynamicCacheBusting Class

Definition

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

Name Description
DynamicCacheBusting(IOptions<DynamicCacheBustingOptions>)

Initializes a new instance of the DynamicCacheBusting class.

Properties

Name Description
Options

Gets the configured options of this instance.

UtcChanged

Gets 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.

See Also