GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - AnderssonPeter/CompressedStaticFiles: asp.net core middleware to send compressed static files to the browser without having to compress on demand, also has support for sending more advanced image formats when the browser indicates that i has support for it.

BranchesTags
Open more actions menu

Latest commit

 

History

151 Commits
151 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
CompressedStaticFiles.Tests
CompressedStaticFiles.Tests
 
 
CompressedStaticFiles
CompressedStaticFiles
 
 
Example
Example
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CompressedStaticFiles.sln
CompressedStaticFiles.sln
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
global.json
global.json
 
 
icon.svg
icon.svg
 
 

Repository files navigation

Logo

CompressedStaticFiles

Send compressed static files to the browser without having to compress on demand, also has support for sending more advanced image formats when the browser has support for it.

· Report Bug · Request Feature ·


NuGet version Nuget run unit tests Coverage Status GitHub license

Table of Contents

  • About the Project
  • Getting Started
  • Example
  • Acknowledgements

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.

Getting Started

Precompress content

Static nonimage files have to be precompressed using Zopfli, Brotli and/or ZStandard, see the example for how to do it with gulp. The files must have the exact same filename as the source + .br or .gzip (index.html would be index.html.br for the Brotli version and index.html.zst for Zstandard).

Encode images

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

ASP.NET

Add AddCompressedStaticFiles() in your Startup.ConfigureServices() method. Replace UseStaticFiles(); with UseCompressedStaticFiles(); in Startup.Configure(). 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 CompressedStaticFileOptions.RemoveImageSubstitutionCostRatio().

Example

A example can be found in the Example directory. By using this package the Lighthouse mobile performance went from 76 to 98 and the transferred size went from 526 kb to 141 kb.

Acknowledgements

This solution is based on @neyromant from the following issue dotnet/aspnetcore#1584 (comment).

About

asp.net core middleware to send compressed static files to the browser without having to compress on demand, also has support for sending more advanced image formats when the browser indicates that i has support for it.

Topics

asp-net-coreavifbrotlicompressiongzipprecompressedstaticfileswebpzopflizopflipngzstandardzstd

Resources

Readme
Apache-2.0 license
Activity

Stars

97 stars

Watchers

8 watching

Forks

19 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.