CacheBuster 1.1.1

A small helper for automatically Cache Busting static assets

Install-Package CacheBuster -Version 1.1.1
dotnet add package CacheBuster --version 1.1.1
<PackageReference Include="CacheBuster" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CacheBuster --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CacheBuster, 1.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CacheBuster as a Cake Addin
#addin nuget:?package=CacheBuster&version=1.1.1

// Install CacheBuster as a Cake Tool
#tool nuget:?package=CacheBuster&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Nuget Build status

CacheBuster

A small helper for automatically cache busting static assets in .NET

How it works

The helper looks at the file's last modified date and sets the timestamp as a queryparamter on the path to the static file. This means that everytime you change the file, the browser cache will update as well.

It's inspired by this article from 2014

How to use

  1. Install the Nuget package
  2. Wrap your static assset paths in the CacheBuster method ➡️

Example

@using CacheBuster;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    <link href="@CacheBuster.GetFullPath("/Content/Site.css")" rel="stylesheet">

    <script src="@CacheBuster.GetFullPath("/Scripts/modernizr-2.8.3.js")"></script>
</head>
<body>
</body>
</html>

Result

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home Page - My ASP.NET Application</title>
    <link href="/Content/Site.css?v=637351943954662093" rel="stylesheet">

    <script src="/Scripts/modernizr-2.8.3.js?v=637351943957222104"></script>
</head>
<body>
</body>
</html>

Contributing to this project

Anyone and everyone is welcome to contribute. Just create a PR with your changes and I will have a look at it.

License

Copyright © 2020 Simon Eldevig

Licensed under the MIT License

Nuget Build status

CacheBuster

A small helper for automatically cache busting static assets in .NET

How it works

The helper looks at the file's last modified date and sets the timestamp as a queryparamter on the path to the static file. This means that everytime you change the file, the browser cache will update as well.

It's inspired by this article from 2014

How to use

  1. Install the Nuget package
  2. Wrap your static assset paths in the CacheBuster method ➡️

Example

@using CacheBuster;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    <link href="@CacheBuster.GetFullPath("/Content/Site.css")" rel="stylesheet">

    <script src="@CacheBuster.GetFullPath("/Scripts/modernizr-2.8.3.js")"></script>
</head>
<body>
</body>
</html>

Result

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home Page - My ASP.NET Application</title>
    <link href="/Content/Site.css?v=637351943954662093" rel="stylesheet">

    <script src="/Scripts/modernizr-2.8.3.js?v=637351943957222104"></script>
</head>
<body>
</body>
</html>

Contributing to this project

Anyone and everyone is welcome to contribute. Just create a PR with your changes and I will have a look at it.

License

Copyright © 2020 Simon Eldevig

Licensed under the MIT License

Release Notes

Handle static files that does not exist on server

Dependencies

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 History

Version Downloads Last updated
1.1.1 177 9/9/2020
1.1.0 150 9/9/2020
1.0.0 160 9/8/2020