Yoyo.Fingerprint 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Yoyo.Fingerprint --version 1.1.0                
NuGet\Install-Package Yoyo.Fingerprint -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yoyo.Fingerprint" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Yoyo.Fingerprint --version 1.1.0                
#r "nuget: Yoyo.Fingerprint, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Yoyo.Fingerprint as a Cake Addin
#addin nuget:?package=Yoyo.Fingerprint&version=1.1.0

// Install Yoyo.Fingerprint as a Cake Tool
#tool nuget:?package=Yoyo.Fingerprint&version=1.1.0                

Build status

Yoyo.Fingerprint

A simple html extension method for handling cache busting on static files (.Net)

It can be used for static files that often require cache busting, such as css and javascript.

It works by taking a hash of the file requested, and using that to change the url, which in turn forces the file to be requested again. The hash is also cached and updated when the file is updated, meaning it won't waste memory.

Requirements

  • IIS URL Rewrite Module installed

The following code in the web.Config

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Yoyo.Fingerprint">
        <match url="([\S]+)(/v-[a-z0-9]+/)([\S]+)" />
        <action type="Rewrite" url="{R:1}/{R:3}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

Installation

NuGet package repository

To install from NuGet, you can run the following command from within Visual Studio:

PM> Install-Package Yoyo.Fingerprint

How to use it

<link href="@Fingerprint.Tag("/css/style.css")" rel="stylesheet" />

// creates

<link href="/css/v-7f2a5d53fbc1758441013d2edbe5ec36/style.css" rel="stylesheet" />
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 2,710 5/16/2019
1.1.0 1,313 7/24/2017
1.0.0 1,064 6/13/2017

The package will now add the Yoyo.Fingerprint namespace and rewrite rules to the Web.config.
It will also remove them when uninstalled.