{"id":13833772,"url":"https://github.com/AnderssonPeter/CompressedStaticFiles","last_synced_at":"2025-07-10T01:32:43.966Z","repository":{"id":9817706,"uuid":"63442404","full_name":"AnderssonPeter/CompressedStaticFiles","owner":"AnderssonPeter","description":"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.","archived":false,"fork":false,"pushed_at":"2024-03-23T19:30:30.000Z","size":3137,"stargazers_count":84,"open_issues_count":4,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-06T08:35:42.232Z","etag":null,"topics":["asp-net-core","avif","brotli","compression","gzip","precompressed","staticfiles","webp","zopfli","zopflipng","zstandard","zstd"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnderssonPeter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"AnderssonPeter","custom":["https://www.paypal.com/donate?business=USVBQ3MG9HFLQ"]}},"created_at":"2016-07-15T18:20:28.000Z","updated_at":"2024-06-21T03:06:55.048Z","dependencies_parsed_at":"2024-01-05T20:51:46.901Z","dependency_job_id":"b8fb9fc1-d41d-4661-8276-38d27567b12e","html_url":"https://github.com/AnderssonPeter/CompressedStaticFiles","commit_stats":{"total_commits":126,"total_committers":9,"mean_commits":14.0,"dds":0.5555555555555556,"last_synced_commit":"06c919b51429549a29fb9b2aa55388a076285420"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnderssonPeter%2FCompressedStaticFiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnderssonPeter%2FCompressedStaticFiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnderssonPeter%2FCompressedStaticFiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnderssonPeter%2FCompressedStaticFiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnderssonPeter","download_url":"https://codeload.github.com/AnderssonPeter/CompressedStaticFiles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225610467,"owners_count":17496279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","avif","brotli","compression","gzip","precompressed","staticfiles","webp","zopfli","zopflipng","zstandard","zstd"],"created_at":"2024-08-04T13:00:25.460Z","updated_at":"2024-11-20T18:31:03.705Z","avatar_url":"https://github.com/AnderssonPeter.png","language":"C#","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/AnderssonPeter/CompressedStaticFiles\"\u003e\n    \u003cimg src=\"icon.svg\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n  \u003ch3 align=\"center\"\u003eCompressedStaticFiles\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    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.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    ·\n    \u003ca href=\"https://github.com/AnderssonPeter/CompressedStaticFiles/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/AnderssonPeter/CompressedStaticFiles/issues\"\u003eRequest Feature\u003c/a\u003e\n    ·\n  \u003c/p\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n[![NuGet version](https://badge.fury.io/nu/CompressedStaticFiles.svg)](https://www.nuget.org/packages/CompressedStaticFiles)\n[![Nuget](https://img.shields.io/nuget/dt/CompressedStaticFiles)](https://www.nuget.org/packages/CompressedStaticFiles)\n[![run unit tests](https://github.com/AnderssonPeter/CompressedStaticFiles/workflows/run%20unit%20tests/badge.svg)](https://github.com/AnderssonPeter/CompressedStaticFiles/actions?query=workflow%3A%22run+unit+tests%22)\n[![Coverage Status](https://coveralls.io/repos/github/AnderssonPeter/CompressedStaticFiles/badge.svg)](https://coveralls.io/github/AnderssonPeter/CompressedStaticFiles)\n[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/AnderssonPeter/CompressedStaticFiles/master/LICENSE)\n\n## Table of Contents\n* [About the Project](#about-the-project)\n* [Getting Started](#getting-started)\n* [Example](#example)\n* [Acknowledgements](#acknowledgements)\n\n## About The Project\nThis 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.\n\n## Getting Started\n\n### Precompress content\nStatic nonimage files have to be precompressed using [Zopfli](https://en.wikipedia.org/wiki/Zopfli), [Brotli](https://en.wikipedia.org/wiki/Brotli) and/or [ZStandard](https://en.wikipedia.org/wiki/Zstd), see the example for how to do it with gulp.\nThe 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).\n\n### Encode images\nModern browsers support new image formats like webp and avif they can store more pixels per byte.\nYou can convert your images using the following tools [webp](https://developers.google.com/speed/webp/download) and [libavif](https://github.com/AOMediaCodec/libavif).\nThe 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).\n\n### ASP.NET\nAdd `AddCompressedStaticFiles()` in your `Startup.ConfigureServices()` method.\nReplace `UseStaticFiles();` with `UseCompressedStaticFiles();` in `Startup.Configure()`.\nBy 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()`.\n\n## Example\nA example can be found in the [Example](https://github.com/AnderssonPeter/CompressedStaticFiles/tree/master/Example) directory.\nBy using this package the Lighthouse mobile performance went from `76` to `98` and the transferred size went from `526 kb` to `141 kb`.\n\n## Acknowledgements\nThis solution is based on @neyromant from the following issue https://github.com/aspnet/Home/issues/1584#issuecomment-227455026.\n","funding_links":["https://github.com/sponsors/AnderssonPeter","https://www.paypal.com/donate?business=USVBQ3MG9HFLQ"],"categories":["Libraries, Frameworks and Tools","Minification","缩率","Audio"],"sub_categories":["Compression","GUI - other"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnderssonPeter%2FCompressedStaticFiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAnderssonPeter%2FCompressedStaticFiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnderssonPeter%2FCompressedStaticFiles/lists"}