Skip to content
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

HttpCompression Not Checking for Already Compressed Content #13

Closed
josh-sachs opened this issue Sep 19, 2016 · 7 comments
Closed

HttpCompression Not Checking for Already Compressed Content #13

josh-sachs opened this issue Sep 19, 2016 · 7 comments

Comments

@josh-sachs
Copy link

josh-sachs commented Sep 19, 2016

Another middleware exists in my pipeline that serves bundled/gziped script and css resources https://github.com/Shazwazza/Smidge

The middleware sets Content-Encoding = gzip since it knows the content it is delivering has already been gziped and cached to disk.

WebMarkupMin does not appear to check the response headers for existing compression before applying its own compression (defaulting to deflate).

I think that if the Content-Encoding header has already been set further down in the pipeline, the WebMarkupMin HttpCompression middleware should be skipped.

In this scenario, content decoding fails at the browser.

Thoughts?

@Taritsyn
Copy link
Owner

Hello, Kudoz83!

In WebMarkupMin 2.2.0 fixed this error.

Thanks for information!

@Taritsyn
Copy link
Owner

Additionally, this hotfix prevents the occurrence of strange error messages:

Category: HTML_PARSING_ERROR
Message: In the start tag <y> found invalid characters.
File: /
Line number: 2
Column number: 41
Source fragment:

Line 1: ������`�I�%&/m�{�J�J��t���`�$ؐ@��������iG#)�*��eVe]f�@�흼��{���{���;�N'���?\fd�l��J�ɞ!����…
Line 2: ��4-��� ��2r�G�!搱R����<^f1�����8,���F��Fn ��wP�z�W����I��    ��_�
------------------------------------------------^
Line 3: �.����������[�y|7N��[v?������ԅ�v�+�YN5̝g��g~k���� ����u��⨒����x����*xL��F���}Q͊�봝�M��U��y�V�O�…

Now, instead of it, displays a more understandable error messages:

Can not apply markup minification to text content, that was encoded in the 'gzip' format.

@5arif
Copy link

5arif commented Dec 16, 2016

hi i get error

Can not apply markup minification to text content, that was encoded in the 'gzip' format.

in azure but work fine in my local server, i use 2.2.2 version in my mvc app <package id="WebMarkupMin.AspNet4.Mvc" version="2.2.2" targetFramework="net462" /> please help

@Taritsyn
Copy link
Owner

Hello, Sarif!

I recommend you to read the “At what point in the run-time process does IIS compress output?” discussion on Stack Overflow.

@Taritsyn
Copy link
Owner

Hello, Sarif!

You deleted own post? Perhaps you have had a problem with the quotes?

@5arif
Copy link

5arif commented Jan 5, 2017

yes i deleted it,. it already working ,. i add

dynamicCompressionBeforeCache="false"

in my web config i just wondering is it possible to handle it from code,.
is it possible to implement compression in json response,. ?

@Taritsyn
Copy link
Owner

Taritsyn commented May 8, 2017

is it possible to implement compression in json response,. ?

@5arif Add a CompressContent attribute to the action method, that returns JSON data.

Also I recommend you to upgrade to version 2.4.0 (there were solved many problems related with HTTP compression).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants