-
-
Notifications
You must be signed in to change notification settings - Fork 508
Enable HTTP compression #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The output was already gzip'ed from other middleware. Did you not get your output compressed? |
|
Hi, no, I'm afraid I'm not getting the content compressed. This is the response headers I get with the original code on my homepage, with a size of 9,91 KB: I didn't notice any Content-Encoding:gzip header, so I went for the compression bits, which give me the following headers: Where the Brotli content encoding header appears, and now the transferred size is 3,65KB. Maybe am I missing something? Which middleware is supposed to be gzipping the response? Thanks! |
|
Since the projects seems a bit abandoned and I would like to recover and maintain, may I ask @sgisbert to replicate this PR into the current fork? I don't want to copy paste the different code enhancements proposed in the original repository.
If at the end of this upgrade @madskristensen wants to integrate in this original repository will be more than welcomed! |
This commit introduces support for HTTP response compression in the ASP.NET Core application. It includes the necessary namespace imports, configuration for Brotli and Gzip compression providers, and enables response compression in the middleware pipeline. JSON responses are also configured to be compressed. Implemented PR: madskristensen#154
* Cleaned and commented. modified: src/BlogSettings.cs modified: src/Controllers/AccountController.cs modified: src/Controllers/BlogController.cs modified: src/Controllers/RobotsController.cs modified: src/Controllers/SharedController.cs modified: src/Models/Comment.cs modified: src/Models/LoginViewModel.cs modified: src/Models/Post.cs modified: src/PostListView.cs modified: src/Services/BlogUserServices.cs modified: src/Services/FileBlogService.cs modified: src/Services/IBlogService.cs modified: src/Services/IUserServices.cs modified: src/Services/InMemoryBlogServiceBase.cs modified: src/Services/MetaWeblogService.cs modified: src/Startup.cs * Removed auto-gen docs modified: src/BlogSettings.cs modified: src/Controllers/AccountController.cs modified: src/Controllers/BlogController.cs modified: src/Controllers/RobotsController.cs modified: src/Controllers/SharedController.cs modified: src/Models/LoginViewModel.cs modified: src/PostListView.cs modified: src/Services/FileBlogService.cs modified: src/Services/IUserServices.cs * Fix some ConfigureAwait issues introduced earlier, add some constants/resources, change index view to use IAsyncEnumerable foreach and modify controller accordingly. modified: src/Controllers/BlogController.cs modified: src/Controllers/RobotsController.cs modified: src/Models/Comment.cs modified: src/Models/Post.cs modified: src/Services/FileBlogService.cs modified: src/Services/IBlogService.cs modified: src/Services/InMemoryBlogServiceBase.cs modified: src/Services/MetaWeblogService.cs modified: src/Startup.cs modified: src/Views/Shared/_Layout.cshtml modified: src/appsettings.json * Update solution and localization files for VS 17.0 - Updated `Miniblog.Core.sln` to Visual Studio version 17.0 and added new global properties for RESX synchronization. - Created new XLIFF files for localization in `en-CA`, `en-GB`, `es-US`, `fr-CA`, and `fr-FR`, enhancing multilingual support. - Updated `Resources.Designer.cs` to reflect the new StronglyTypedResourceBuilder version. - Modified `.resx` files to include a new XML schema and updated resource entries for compatibility with the latest standards. * Update package references and resource settings Upgraded versions of several packages in `Miniblog.Core.csproj`, including `JavaScriptEngineSwitcher.V8`, `LigerShark.WebOptimizer.Core`, `Microsoft.ClearScript.V8.Native.win-x64`, and `WebMarkupMin.AspNetCoreLatest`. Changed the `CopyToOutputDirectory` property for `Properties\Resources.resx` from `Always` to `PreserveNewest`. * Refactor .NET application and update configurations - Updated `.editorconfig` for coding styles and preferences. - Refactored classes in `BlogSettings.cs`, `Constants.cs`, and `AccountController.cs` for improved readability and maintainability. - Modified `Miniblog.Core.csproj` to enable .NET analyzers and enforce code style. - Enhanced `FileBlogService.cs` and `MetaWeblogService.cs` for better handling of posts, categories, and tags. - Updated `Startup.cs` for service and middleware configuration, including output caching and authentication. - Added `workload-install.ps1` script for installing Tizen workload manifests. - General code structure improvements, including expression-bodied members and better null handling. * Remove Microsoft.CodeAnalysis.NetAnalyzers package This commit removes the `Microsoft.CodeAnalysis.NetAnalyzers` package reference from the `Miniblog.Core.csproj` file. The package was previously included with version `9.0.0` and had specific asset inclusion settings, which are no longer needed in the project. * Add log level for Microsoft.AspNetCore in settings Updated appsettings.Development.json and appsettings.json to include a new log level for Microsoft.AspNetCore, setting it to "Warning". The existing log level for Microsoft remains unchanged at "Information", and the default log level in appsettings.json remains "Warning". * Refactor app setup to use minimal hosting model Moved application configuration from Startup.cs to Program.cs, aligning with .NET 6 practices. Added services for authentication, output caching, HTML minification, and Progressive Web Apps. Removed Startup class and integrated its methods into the new builder pattern for a simplified application structure. * Enhance slug handling and input validation Updated `UpdatePost` method for better null checking and slug creation. The `CreateSlug` method now accepts a `maxLength` parameter to limit slugs to 50 characters and truncates titles as needed. The `Edit.cshtml` file enforces a maximum length of 50 characters for the slug input field. Implemented upstream PR: #195 * Add HTTP response compression support This commit introduces support for HTTP response compression in the ASP.NET Core application. It includes the necessary namespace imports, configuration for Brotli and Gzip compression providers, and enables response compression in the middleware pipeline. JSON responses are also configured to be compressed. Implemented PR: #154 * Enhance pagination and improve code clarity - Added `PostsPerPage` and `TotalPages` constants in `Constants.cs`. - Refined comments in `AddComment` method of `BlogController.cs`. - Improved pagination logic in `Category` and `Index` methods, replacing `filteredPosts` with `pagedPosts`. - Updated comments in `Post` method and added a new `Tag` method for tag-based post display. - Modified `UpdatePost` to accept a `slug` parameter for better post handling. - Enhanced comments and consistency in `SaveFilesToDisk` method. - Updated `Index.cshtml` to accurately calculate `currentPage` and `totalPages` using new view data properties. Implements PR: #149 Issue: madskristensen/MiniBlog#262 * Refactor file handling and improve performance - Streamlined `SaveFile` method with concise `using` syntax. - Added null-forgiving operators in `SavePost` for safety. - Replaced `ForEach` with `foreach` in `LoadCategories` and `LoadTags`. - Updated `Initialize` to call `LoadPosts` asynchronously. - Refactored `LoadPosts` to use PLINQ and async enumerables for parallel file loading. * Refactor FileBlogService for asynchronous initialization Updated the constructor to call an asynchronous method, `InitializeAsync`, instead of a synchronous one. This change allows for proper handling of asynchronous operations during initialization. The `LoadPosts` method is now awaited, ensuring that posts are loaded correctly before sorting the cache. * Refactor methods for asynchronous operations - Changed `GetCategories` to return `IAsyncEnumerable<string>` for asynchronous streaming. - Updated `GetPostById` and `GetPostBySlug` to be asynchronous, using `Task<Post?>` and `async` keyword. - Modified return statements to use `await Task.FromResult(...)` for better async handling. * Refactor FileBlogService for improved structure Updated FileBlogService to use constructor injection for dependencies, added SuppressMessage attributes for security, and changed folder handling to a property. Implemented async methods with yield return for better performance and ensured initialization checks are in place. Simplified IsAdmin method and improved overall readability and maintainability. * Create dotnet.yml * Update .NET version in workflow configuration Changed the `dotnet-version` in the `Setup .NET` step from `8.0.x` to `9.0.x` to utilize the latest .NET version for the workflow. * Create dependabot.yml


Just added the bits to enable HTTP compression, in case you might consider it is worthy :)