Pre-compressed static files in self host Asp.Net Core

When using StaticFileMiddleware and ResponseCompressionMiddleware, each file is read from slow disk uncompressed and then dynamically compressed (consuming CPU each time). It’s clearly ineffective in terms of CPU, disk and time.

A better approach is to pre compress some files on disk, mark them as already compressed using some kind of metadata and return them as is if compression is accepted or decompressed them dynamically.

This library provides a middelware to do it: AnderssonPeter/CompressedStaticFiles: asp.net middelware for Kestrel to serve precompressed static files.

It started with Use pre-gzipped content files? GitHub #1584.

 

EDIT: Also found a non core implementation. More limited but (gz only) but usefull: https://github.com/damianh/StaticFilesMiddleware (it’s a StaticFilesMiddleware replacement).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s