dotnet add package CompressedStaticFiles.AspNet --version 1.0.0
NuGet\Install-Package CompressedStaticFiles.AspNet -Version 1.0.0
<PackageReference Include="CompressedStaticFiles.AspNet" Version="1.0.0" />
paket add CompressedStaticFiles.AspNet --version 1.0.0
#r "nuget: CompressedStaticFiles.AspNet, 1.0.0"
// Install CompressedStaticFiles.AspNet as a Cake Addin #addin nuget:?package=CompressedStaticFiles.AspNet&version=1.0.0 // Install CompressedStaticFiles.AspNet as a Cake Tool #tool nuget:?package=CompressedStaticFiles.AspNet&version=1.0.0
Table of Contents
About The Project
This project allows you to serve 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 Gzip and/or Brotli, see the example CompressedStaticFiles.csproj for an automated methodology for producing compressed css & js files.
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 formats 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
An 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 developed from a clone of AnderssonPeter/CompressedStaticFiles, which was based upon work by @neyromant from the following issue ASP.NET Issue #1584.
We built this cloned project because:
- We wanted to update to the currently supported version of .NET;
- To make some refinements that were to our taste; and
- To add MSBuild code to the example CSPROJ file to build Brotli and Gzip compressed CSS and JS files, using a method contributed by SQL-MisterMagoo.
|.NET||net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows|
- No dependencies.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.