Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6707265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:37:07+00:00 2026-05-26T07:37:07+00:00

Yesterday I activated compression on my website, like this: void context_BeginRequest(object sender, EventArgs e)

  • 0

Yesterday I activated compression on my website, like this:

void context_BeginRequest(object sender, EventArgs e)
{

    HttpApplication app = (HttpApplication)sender;
    string encodings = app.Request.Headers.Get("Accept-Encoding");

    if (encodings == null)
        return;

    string url = app.Request.RawUrl.ToLower();           


    if (url.Contains(".js") || url.Contains(".aspx") || url.Contains(".css") || url.Contains("ajax.ashx"))
    {

        Stream baseStream = app.Response.Filter;
        encodings = encodings.ToLower();

        if (encodings.Contains("gzip"))
        {
            app.Response.Filter = new GZipStream(baseStream, CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "gzip");
        }
        else if (encodings.Contains("deflate"))
        {
            app.Response.Filter = new DeflateStream(baseStream, CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "deflate");
        }
    }
}

Last night, people were complaining about the styles for the website being broken. I tried the site in Firefox and Chrome and got the same problem until I did a forced refresh, clearing the cache.

This morning, I opened Safari to see what it looked like in that browser, and checked the stored style sheets. Here is a section of the top line:

���`I�%&/m�{J�J��t��`$ؐ@�������iG#)�*��eVe]f@�흼��{����{����;�N'���?\fdl��J�ɞ!���?~|?"�~+M�m�?��{�7y����l]�餮���N���̛�x�Ϋ�Q�cMVg��

I think either Safari has tried to uncompress something that was not compressed to begin with, or else it has recieved a compressed file and not decoded it.

Is this a one-time problem, that will be cleared up as soon as visitors to my site clear their cache, or have I made a mistake in writing my HttpCompression function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:37:08+00:00Added an answer on May 26, 2026 at 7:37 am

    I believe my problem here was related to my lack of a Vary:Accept-Encoding header being added to my responses. Please see this related question on the subject. My code now looks like this:

    if (url.Contains(".js") || url.Contains(".aspx") || url.Contains(".css") || url.Contains("ajax.ashx"))
    {
        app.Response.AppendHeader("Vary", "Accept-Encoding");
    
        encodings = encodings.ToLower();
    
        if (encodings.Contains("gzip") || encodings == "*")
        {
            app.Response.Filter = new GZipStream(baseStream, CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "gzip");
    
        }
        else if (encodings.Contains("deflate"))
        {
            app.Response.Filter = new DeflateStream(baseStream, CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "deflate");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday, I found myself writing code like this: SomeStruct getSomeStruct() { SomeStruct input; cin
Yesterday i tried to create an object for this class to be able to
Yesterday, I asked this question and never really got an answer I was really
Yesterday, I discovered the Subversion (SVN) blame feature, and I was wondering, is this
Yesterday I found this function: function clone(obj) { return typeof obj === 'undefined' ?
Yesterday I created this piece of code that could calculate z^n, where z is
Yesterday I asked this post , but I am still having problems when I
Yesterday, I had programmed a simple Bluetooth network for my iPhone application. This morning,
Yesterday I found that I needed to add self to an object as it
Yesterday i asked this question: Get current time and set a value in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.