Install-Package CompressedStaticFiles -Version 2.0.0
dotnet add package CompressedStaticFiles --version 2.0.0
<PackageReference Include="CompressedStaticFiles" Version="2.0.0" />
paket add CompressedStaticFiles --version 2.0.0
#r "nuget: CompressedStaticFiles, 2.0.0"
// Install CompressedStaticFiles as a Cake Addin #addin nuget:?package=CompressedStaticFiles&version=2.0.0 // Install CompressedStaticFiles as a Cake Tool #tool nuget:?package=CompressedStaticFiles&version=2.0.0
Table of Contents
About The Project
This project allows you to server precompressed files to the browser without having to compress on demand, this is achieved by compressing/encoding your content at build time.
Static nonimage files have to be precompressed using Zopfli and/or Brotli, see the example for how to do it with gulp.
The files must have the exact same filename as the source +
index.html would be
index.html.br for the Brotli version).
Modern browsers support new image formates like webp and avif they can store more pixels per byte.
You can convert your images using the following tools webp and libavif.
The files must have the same filename as the source but with a new file extension (
image.jpg would be
image.webp for the webp version).
AddCompressedStaticFiles() in your
By default CompressedStaticFiles is configured to allow slightly larger files for some image formats as they can store more pixels per byte, this can be disabled by calling
A example can be found in the Example directory.
By using this package the Lighthouse mobile performance went from
98 and the transferred size went from
526 kb to
This solution is based on @neyromant from the following issue https://github.com/aspnet/Home/issues/1584#issuecomment-227455026.
- No dependencies.
- No dependencies.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
Added support for alternative image formats
Added support for .net 5
Removed support for .net core 2.1
Added support for .net core 3.1
New feature: Ability to specify a custom FileProvider (now using the FileProvider provided in the StaticFileOptions if it is set)
Converted to .NET Standard 1.6
Fixed issue that disabled caching parameters.
Added support for IIS.
Picks original file if its the smallest
Added support for .NETFramework 4.5.1