About the author

Miron Abramson
Me
Software Engineer,
CTO at PixeliT
and .NET addicted for long time.
Open source projects:
MbCompression - Compression library

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014

Creative Commons License

Blog Flux Directory
Technology Blogs - Blog Top Sites

New & Shiny WebResource.axd compression Module

This project is now an Open source project on  CodePlex web site. Latest code and updates can be found at  http://www.codeplex.com/MbCompression

Background

Running after the best performance for your web application, one of the biggest improvement you can do is to use compression. Page, Stylesheet & Javascript files (images are already compressed format). There are few compression modules out there, all you needs to do is just 'goolge' for it, and the implementation is really very simple. Not a lot of changes in your code are needed.

ASP.NET bring us a new way to integrate resources into our site - using WebResource.axd handler. Those are like a 'Virtual containers' for other file that embedded into a DLL file. It can be Css, Javascript, Images... Actually this is an handler that load the resource from the DLL file. 

The Problem

The pages, .css & .js files can be easily compress with one of the modules on the net. The basic technique is to pass your response through 'Compression Filter'.

WebResource.axd, that became very large (specially when using AJAX) are break down for unknown reason when you try to compress them that way. That result is you will not compress them, and your client will download big files that contains js or css (sometimes of 70kb and even more)

The Challenge

I couldn't find on the net a compression module that compress this type of file. I decided I will try to do it by myself.

First Try.  Working, but bad performance. ( Compress pages and WebResource.axd files in ASP.NET )

I started to make tests and to play with WebResources files. Only WebResources that contains 'text' content (css, js, text) can be consider as compressible. Images are not.

I was thinking, maybe I can load the WebResource, get it's content as string, compress the string and send it to the response as string (or as byte[]). After some tests, It discovered as true. The WebResource was passing to the client completely and without any missing characters. The problem was to get the WebResource content. For that, I had to make a 'fake' request based on the url, asking again for the WebResource and then compress it.

HttpWebResponse request = (HttpWebRequest)WebRequest.Create(app.Context.Request.Url.OriginalString + "&p=1");
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream responseStream = response.GetResponseStream();

That make every time the client ask for webresource, the server made double HTTP request - what a waste.

This module was working. It was actually compressing the WebResources, But suffer from bad performance.

Second Try. Working better. But not enough. ( Compress your pages, css, js and WebResources.axd files for better performance )

Thanks to Mads Kristensen that point me to the performance issue and offer an idea how to improve it, The second try was better. The first time the WebResource was loading, it was compressed and inserted into the Application object, and next time it was requested, it was served from there directly.

It was actually running on our production servers (Where I work) for a while, and compressed the WebResources. But I was not happy with that solution. The 'fake' request throw an exception once in a while. Maybe one for some thousands of users. Also it was not stable enough on some other servers, and throw 404 errors.

Third Try.  Success! Working as expected. No errors and really WebResource compression module!

The compression part in the first two tries was perfect. compress the content of the webresource as byte[] and serve it to the client. The only problem is to load the actual resource content.

In this time, I decided to 'attack' the problem from another way. .NET using System.Web.Handlers.AssemblyResourceLoader to load and serve WebResource requests. I decided to implement my own AssemblyResourceLoader handler that will support compression. unfortunately,  AssemblyResourceLoader handler is registered into the system, and can't be remove. Any try to do so will lead you to an exception.

So, what I did was to create an HttpModule, using the event PreRequestHandlerExecute that is one step before the handle action, do my stuff here, and then end response and jump over the hander step. That way I can prevented AssemblyResourceLoader handler to do his stuff.

To create my version for the AssemblyResourceLoader, I used the source code of 'ASP.NET 2.0 AJAX Extensions' and a reflector to see the code of the original AssemblyResourceLoader.

There are few steps in that module:

1.  Parsing the request query string. The request for WebResource has an encrypted query string with the the resource data separate with pipes chars ('|'):     Assemby info,  Resource name and a char for the 'assembly type'. The query string is encrypted using the machinekey, and needs to be decrypted using reflection. The problem is, that share hosting servers (such GoDaddy) are not permitting using reflection from within your code. Only from assemblies that are in the GAC. What I had to do is to find a public method from an assembly that in the GAC of every server.

The solution I found (if somebody have a better idea, I will be glad to hear) is creating an empty Membership class, that inherits from MembershipProvider, and implement only one public method that using the 'DecryptPassword' method from the  MembershipProvider. it is also using the machinekey.   (To use that decryption, add the attribute reflectionAlloweded="false" to the CompressorSettings section, and machinekey section to the web.config. See Readme.txt file in the source)

private static MethodInfo _decryptString;
private static readonly Object _getMethodLock = new Object();

internal static string DecryptString(string input)
{
    if (Settings.Instance.ReflectionAlloweded)
    {
        if (_decryptString == null)
        {
            lock (_getMethodLock)
            {
                if (_decryptString == null)
                {
                    _decryptString = typeof(Page).GetMethod("DecryptString", BindingFlags.Static | BindingFlags.NonPublic);
                }
            }
        }
        return (string)_decryptString.Invoke(null, new object[] { input });
    }
    else
    {
        return EmptyMembership.Instance.DecryptString(input);
    }
}

2.  Load the assembly. The char for the 'assembly type' in the query string indicate if the assembly is the System.Web assembly or the one that encrypted in the query.

3.  Load the resource info. Using the resource name from the query, we need to load the resource info - it's content type, if it exist and if it needs to perform substitution calls      (WebResource within another WebResource. If so, we let the original System.Web.Handlers.AssemblyResourceLoader to handle this WebResource). Of course we check in our cache if that resource already asked for, and load the info from the cache.

4.  Setting the HttpCachePolicy headers to cache the request, and adding a ETag for checking in the next time.

5.  Get the resource stream from the assembly.

    Stream resourceStream = assembly.GetManifestResourceStream(resourceName)

6. Compress the resource stream if needed. If the resource is 'compressable' it can be read as a string, so we load it as StreamReader, read it to the end, convert the string into byte[] and compress it. If not (in case of images) we just load the resource, and serve it to the client.

     public static byte[] Compressor(byte[] buffer, string encodingType)
     {
         using (MemoryStream memStream = new MemoryStream())
         {
             Stream compress = null;

             // Choose the compression type and make the compression
             if (String.Equals(encodingType, "gzip", StringComparison.Ordinal))
             {
                 compress = new GZipStream(memStream, CompressionMode.Compress);
             }
             else if (String.Equals(encodingType, "deflate", StringComparison.Ordinal))
             {
                 compress = new DeflateStream(memStream, CompressionMode.Compress);
             }
             else
             {
                 // No compression
                 return buffer;
             }

             compress.Write(buffer, 0, buffer.Length);
             compress.Dispose();

             return memStream.ToArray();
         }
     }

7.  Last thing to do, is to send the byte[] (compressed or not to the response stream, and end the response.

      HttpContext.Response.OutputStream.Write(compressedData, 0, compressedData.Length);

Optional Improvements for the WebResource module (maybe in the feature) 

  • Storing the compressed resource in the HttpContext.Cache
  • Compress using the preferred compression algorithm by the client (parsing the 'Accept-encoding' header)
  • Remove white spaces & comments from css & Javascript resources

Tips when working with WebResources

  • Add to your robots.txt file the following:
    User-agent: *
    Disallow: /*.axd$
  • To prevent the search engines to cache the axd handlers. (not 100% solution, but not harmful Cool)

  • Add a machinekey to your Web.Config. ASP.NET use it for validation and encryption/decryption of the view state & the WebResource query strings. Don't relay on the auto generate key. It can lead you to some Cryptographic Exceptions. Use one of the on-line tools to generate key for you. 

Implementation

Full instruction can be found in the readme.txt file in the source code.

The Source Code

The source code contain handlers to compress .js & .css files, simple module to compress pages, the module to compress the WebResources and helper classes. Every module/handler is 'stand alone' and can be use independent in case you choose to use your own implementation for the pages of css/js.

The Readme.txt file include all needed info to implement the handlers/modules.

Important: If you are using the WebResource compression module on share hosting thatnow allowed using reflection from your code (as GoDaddy), you must  add the attribute reflectionAlloweded="false" to the CompressorSettings section.

Latest code can be downloaded from: http://www.codeplex.com/MbCompression

See also post:  Update to my compression module to compress third party scripts 

Currently rated 4.5 by 15 people

  • Currently 4.466668/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Miron on Saturday, October 13, 2007 5:59 AM
Permalink | Comments (137) | Post RSSRSS comment feed

Related posts

Comments

Olivier fr

Monday, October 15, 2007 12:46 AM

Olivier


Great, thank you very much for this update !

Would it be possible to add in OnPostReleaseRequestState, where without gzip or deflate, which would:

// Check if GZIP is supported by the client
if (RequestUtil.IsSpecificEncodingSupported(app.Context, Constants.GZIP))
{
app.Response.Filter = new GZipStream(app.Response.Filter, CompressionMode.Compress);
ResponseUtil.SetEncodingType(app.Context.Response, Constants.GZIP);
}
// If GZIP is not supported, so only DEFLATE is : case with a console client which calls an aspx : no gzip, no deflate
else
{
if (RequestUtil.IsSpecificEncodingSupported(app.Context, Constants.DEFLATE))
{
app.Response.Filter = new DeflateStream(app.Response.Filter, CompressionMode.Compress);
ResponseUtil.SetEncodingType(app.Context.Response, Constants.DEFLATE);
}
}

...and sorry for my poor english Wink

Miron il

Monday, October 15, 2007 2:25 AM

Miron

Yes, its possible, but the second check
if (RequestUtil.IsSpecificEncodingSupported(app.Context, Constants.DEFLATE)) is not needed,
because in the method
RequestUtil.IsCompressionSupported(HttpContext.Current,true)
we check if at least one of the compression type is supported.
So if we passed this condition, that's mean that GZIP or DEFLATE is supported, therefore, if GZIP
is not supported, for sure DEFLATE is. ;-)

Victor ru

Friday, October 26, 2007 3:51 PM

Victor

Hi Miron!
Great module!

Is it possible to combine multiple references to WebResource.axd on a page into one reference? It should increase page loading performance.

Fargii gb

Monday, October 29, 2007 6:27 PM

Fargii

Hello Miron,

First of all thank you for working hard to come out with such a module for compression, no doubt many people out there need it.

I have been using an Http compression module by darick_c available from the code project site:www.codeproject.com/aspnet/httpcompression.asp. My problem with that module is that it doesn't support post cache substitution, which is a big problem for me, because I run a site which involves membership registration and all. My question is, does this module support caching and post cache substitution? Thank you.

Fargii

Miron il

Tuesday, October 30, 2007 8:54 AM

Miron

Victor,
I think it will be impossible, (maybe somebody will find the way one day) due some reasons:
1. WebResources can "contain" some mime types (css, js, images) and of course you can't combine some types.
2. WebResources usually come from different resources (dlls) and not directly from your code, and the reference url
is "injected" into the html, so it is harder to control it.
Anyway, I will think about it...
Thanks

Miron il

Tuesday, October 30, 2007 9:08 AM

Miron

Hi Fargii,
I took a look on that module, it nice, but suffer from the same sickness of my first two tries (see the post) -
Every time the browser requests the WebResource.axd handler this module created an HTTP request - A big overhead.
In my module, this "sickness" is gone, and the performance is much better.
You shouldn't expect to have problem with the membrship with my module. I run several sites with membership and registration, and no problem at all.
Good luck,
Miron

tolis gr

Thursday, November 08, 2007 9:28 AM

tolis

i have tried your module with telerik's treeview control but i m getting 403 status code and the javascripts are not d/l at all

Miron us

Thursday, November 08, 2007 10:19 AM

Miron

Hi Toils,
If you will give me a little bit more info, I will be able to help you.
Do you get an exception? does all the page loading right except the WebResource ? do it happen only with the treeview control ?
Does it happen also if you run your application on your local machine?
I tested my module with some Telerik's controls, and it work perfect. Telerik's control have VERY big webresource files, and the compression will really improve your site.

fargii gb

Sunday, November 11, 2007 7:55 PM

fargii

Hello again Miron,
I have tried your module. It works fine with my site except for 1 thing (as is always the case), I am unable to do postbacks, let's say a search, when you click search button, the form is not submitted (The postback is sort of blocked). I am using urlrewritting.net for my url rewrittting. I have tried using an actionless form. Once I take out your module, postbacks work again. Any clues will be appreciated.

Cheers.

fargii gb

Monday, November 12, 2007 1:16 AM

fargii

Hi Miron,
I found why I had the problem posted above, I set reflectionAlloweded="false" in CompressorSettings. When I changed it to true,
validation worked, and so postbacks started working again.

Just a thought, It is possible to combine all css files into 1 file, and javascript files into 1 file in the CssCompressionHandler and JavascriptCompressionHandler classes. That should result in some performance gain. The files could be comma separated in the form
<script type='text/javascript' src='Scripts/jslib.axd?d=~/js/a.js,~/js/b.js,~/js/c.js,~/js/d.js'></script>
<script type='text/javascript' src='Scripts/css.axd?d=~/css/1.css,~/css/2.css,~/css/3.css,~/css/4.css'></script>

The beginning of ProcessRequest will look like so:

string file = context.Server.UrlDecode(context.Request.QueryString["d"]);

// get list of files
string[] tempFiles = file.Split(',');

// determine the last modification date of the files
foreach (string file in tempFiles)
{
string tempfile = file.Replace("/", "\\"Wink;
}

StringBuilder fileText = new StringBuilder();
foreach (string file in files)
{
fileText.Append(File.ReadAllText(file));
fileText.Append(Environment.NewLine);
fileText.Append(Environment.NewLine);
}
// Add some new lines so javascript doesn't get cut off
fileText.Append(Environment.NewLine);
fileText.Append(Environment.NewLine);

Well, what do you think, can it be done, if so please point me in the right dxn.

Cheers.
Fargii

tolis gr

Thursday, November 15, 2007 7:38 AM

tolis

Hi again Miron

that was my mistake (partial trust) it works now.
well almost try the following create a derived class from telerik's RadEditor and try to compress it u get resource not found exceptions.
i do not know why but it seachres to wrong assembly to get the resources thats the reason
couldn't figure out a fix though

Peter

Saturday, November 24, 2007 2:35 AM

Peter

Hi Miron, great code here:

But you mention on this page:
mironabramson.com/.../...ules--Implementation.aspx

"usualy this method will be place in our BasePage", well how can I achieve that? Where can I find this BasePage class? Could you provide me some steps to implement this? Im a bit new to .NET...Smile

Thanks and keep up the good work.

Cheers,
Peter

Miron il

Saturday, November 24, 2007 11:41 AM

Miron

Usually, In a web project, there is a class that inherits from System.Web.UI.Page , and all the other pages inherit from this class.
In this class you put all the 'share' or 'common' things between all the pages.
You can place this class in the App_Code folder or in a DLL.

Peter

Saturday, November 24, 2007 9:20 PM

Peter

well...this is on top of all my pages:
Partial Class <name>
Inherits System.Web.UI.Page

So my pages already inherit directly from System.Web.UI.Page...

ps: (sorry to bother you with these basic questions Smile)

Andreas Ekdahl se

Tuesday, December 11, 2007 7:28 AM

Andreas Ekdahl

Hey Miron. Your component is so perfect. excellent work. I have a problem though.
when i enable page compression it kills another component i am using.

http://www.xepient.com/ViewStateServer.aspx

this component saves the viewstate on the server in a xml file and also runs as a httpmodule.
when i add
<add name="PageCompressionModule" type="Miron.Web.HandlersAndModules.PageCompressionModule"/>
to the web.config it just stops saving the viewstate on the server and renders it on the page anyway.
Do you have any idea why this could be. I havent found any better component then yours so i hope that
this can be solved.

best regards
andy

Miron il

Tuesday, December 11, 2007 1:38 PM

Miron

Hi Andreas,
I guess it happen because that component can't find what it is looking for in the context because of the compression happen before.
All because the response filters order.
Since I don't know the events that component is using I can't help too much.
Try to change the order of the httpmodules in the web.config
Also I don't have that component, I can't try it on my machine. (mybe you can send me that component)

Surf us

Thursday, December 13, 2007 10:46 AM

Surf

Hello,

I am trying to use the compression on the .aspx pages and webresource.axd files for my 2.0 web app. I've followed your instructions about putting the DLL in the bin folder and adding the modules for both page and webresource compression pieces to the httpmodules section. However, nothing I do will get compression to work on the webresource.axd files. Fiddler shows no compression is used and the file size is not reduced. The .aspx pages are compressing. Any ideas what I'm doing wrong? I also tried using the configuration section to no avail.

thanks, Surf

Miron il

Thursday, December 13, 2007 12:46 PM

Miron

Hi Surf,
If you followed exactly my instructions and your site is working ok without any exceptions and the Webresources are not compressed,
The only thing that can cause them not to be compressed is that they have to perform substitution (Webresource that contains calls to other Webresource or itself) this is the only case that it will not be compressed.
You can download the full source and debug it. You need to see in the class 'WebResourceCompressionModule.cs' the lines:
if (resourceInfo.Second)
return;
if the execution stop here.
Keep update me.

Ewart nz

Wednesday, February 13, 2008 10:48 AM

Ewart

Hi Miron, great work, thankyou! Did IE6 previously not support compression? It seems to (now anyway?) so in RequestUtil.cs line 39 so I have changed 7 to 6:

if (context.Request.Browser.MajorVersion < 7 && !isPage)
return false;

When you have tried this with the Telerik framework have you sucessfully got to to compress the JS and CSS files that telerik's controls automatically insert into the response? it inserts code like:

<link type="text/css" rel="stylesheet" href="/Code/RadControls/TabStrip/Scripts/3_6_3/tabstrip.css" />

They are inserted into the <head> section but not found by PrepareToCompressCSS() so it appears this solution will only work with self written JS/CSS files and not frameworks like Telerik. Hopefully I am wrong about this? - but this is the main reason I need compression - the framework is several mb in size and there are probably thousands of us in this situation where the bulk of the download is the JS and CSS.

Regards
Ewart

Miron Abramson il

Friday, February 15, 2008 8:34 AM

Miron Abramson

Hi Ewart,
About the browser version, I won't recommend you to change it to '<7' duo the fact that even Microsoft use the same condition in their ScriptResourceHandler (the component that in charge to handle all the AJAX resources - include compress them):
private static bool IsCompressionEnabled(HttpContext context)
{
if (!ScriptingScriptResourceHandlerSection.ApplicationSettings.EnableCompression)
{
return false;
}
if ((context != null) && context.Request.Browser.IsBrowser("IE"Wink)
{
return (context.Request.Browser.MajorVersion > 6);
}
return true;
}
(Thats Microsoft code !!!)
About the RadControls, it will not be difficult to modify a little my code and make it works with the RadContols.
You can see that the method 'PrepareToCompressCSS()' 'preparing' only css links that begins with '~' (to make it easier to find it's physical location). You can change it, and also change in the class 'CssCompressionHandler.cs' the way it loads the file from the disk.
That should work perfect and no too much code changes.
Good luck

Ewart nz

Friday, February 15, 2008 9:30 AM

Ewart

Hi Miron, firstly thanks for your reply. If I can get compression working with the Telerik framework and post a solution it will make a substantive difference to a lot of people, starting with me Smile My website is presently almost unusable on slow broadband connections due to their huge libraries.

Anyway, I did actually try that already but telerik's controls are _automatically_ inserted into the head section of the response by their library but are not found by PrepareToCompressCSS().. I did debug-step through that again just now to double check and none of the Page.Header.Controls are telerik stylesheets.

Perhaps I have missed something? Seems the framework is inserting the links after the Page_PreRender or Page_PreRenderComplete events. I know you say you've tested your module with some Telerik's controls, and it work perfect, but I'm wondering it if "ran fine" but did not actually compress the pages perhaps?

regards
ewart

Miron us

Sunday, February 17, 2008 10:03 AM

Miron

I played around with the Telerik contols.
The css files are really small. The problem is with the script files that are big.
I looked on the Telerik support forums and I couldn't find where they recommended not using WebResources.
There is no disadvantage of using WebResources, more than that, if you use the Webresources, you will be able to compress them (using my module) and they will be caches in the client machine.
Personally, I recommended you to use the Webresources and use my compresssion module for best performance.

Good luck

Ewart nz

Sunday, February 17, 2008 12:59 PM

Ewart

Hi Miron, I didn’t think you’d be able to solve the problem of teleriks external files but thanks very much for trying, it’s really appreciated.

I don't want people to think there are "no disadvantages" to using web resources so here's a reference to Telerik's Todd Angin in his own blog with advice including Tip #9, "Use External Resources instead of EmbeddedResources". In summary using the embedded resources can increase your page size anywhere from nothing to 100%.
blogs.telerik.com/.../...tion_Tips_and_Tricks.aspx

I have found Todd's advice to be accurate however I suspect the disadvantage of webresources would be outweighed by the benefits of compression, assuming the client supports compression - which if I follow your earlier advice of disabling IE6 compression leaves about 32% of people in an even worse off position due to the increased page size of webresources (as at feb 08). My IE6 does seem to suport compression so I'm pretty tempted to turn it on! I wonder if anyone knows if there is a specific minor/major version whereby compression can be enabled for IE6.

All the best
Ewart

Miron il

Monday, March 10, 2008 1:07 PM

Miron

Hi Ewart,
By saying: "I didn’t think you’d be able to solve the problem" you throw me a big challenge.
I worked a little and I have a solution (even I think there is nothing bad with WebResources ;-) ).
Check the new post:
mironabramson.com/.../...-third-party-scripts.aspx

ewart nz

Monday, March 10, 2008 1:33 PM

ewart

Awesum, well done Miron, you have indeed kicked some ass here solved the problem - avoiding the injection of long winded EmbeddedResource tags yet still managing to compress outgoing HTML and JavaScript for the third party controls. This will improve life for what will be a large number of Telerik customers!! (and probably others).

Your module is the ONLY one I've found (after much research and wasted time trying other modules). I'll put a reference back in the client area for telerik pointing to your solution.

Excellent work, it really works well.

Cheers
Ewart

Sander Soeteman nl

Tuesday, March 25, 2008 11:41 PM

Sander Soeteman

Good stuff!

Very elegant solution. This way I didn't have to dig in my client's IIS settings and it enables me to deliver everything as a complete package/build.

Thanks a bunch!

Ch. Adeel sa

Tuesday, May 27, 2008 8:42 PM

Ch. Adeel

Hi!
after using the script manager tag on page the WebResources files which are generated have the size of 460 kb aprox. so if i apply this ScriptMode="Release" they are reduced to 260 Kb. plz tell me is it correct way to reduce the size of files generated as the result of usage of script manager tag in page also should i use it during using the .dll file provided by you

Miron il

Tuesday, May 27, 2008 11:24 PM

Miron

@Adeel,
The ScriptManager will compress the ScriptResource.axd and not the WebResource.axd
To compress the WebResource.axd you have to use my library.

Hemant in

Friday, May 30, 2008 1:32 AM

Hemant

Hi Miron,
I have referenced your lib (HandlersAndModules 1.0.1.5) to my ASP.NET 2.0 application (developed for facebook - an IFrame based application). I have to reference the one the js file from within the AJAX ScriptManager tag as shown below:

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Name="MicrosoftAjax.js"
Path="~/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js"
ScriptMode="Auto" />
</Scripts>
</asp:ScriptManager>

I don't know how to include the jslib.axd but I have tried changing the above path reference as Path="jslib.axd?d=~/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js". I get error like "path must end with .js". For only this js file i 'm not able to include jslib.axd and moreover the size is around 240K. I 'm testing this from Firefox 2.0.0.14 using yslow plugin. In that i see other js files are showing as gzipped. Can you guide me to achieve this.

Apart from the above problem, I have one more question.
why have not done in this way: <add verb="*" path="*.js" type="Miron.Web.HandlersAndModules.JavaScriptCompressionHandler" validate="false"/> instead of <add verb="*" path="jslib.axd" type="Miron.Web.HandlersAndModules.JavaScriptCompressionHandler" validate="false"/>

Expecting your reply eagerly and can't wait to see the gain in performance Smile
Thanks and Regards,
Hemant.

Miron il

Friday, May 30, 2008 1:57 AM

Miron

@Hemant
About the first part of your question, ScriptManager is part of the Microsoft Ajax framework. I need to see what it is doing.
I will investigate it later.
About your second question, the part path="*.js" will work fine if you run your site within the VS but on an IIS it will not work (unless you will configure it) the js extensions are not being served by the .NET 'engine' so the requests from this type will not pass through your modules. axd are extensions that configured to pass through the .NET 'engine' so your can handle them in your modules/handlers.

Ch. Adeel sa

Friday, May 30, 2008 9:50 AM

Ch. Adeel

Hi!
i have added the lines in http modlues and http handlers and have added the following code after system.web

<Miron.web>
<CompressorSettings reflectionAlloweded="false" daysInCahe="30" optimizeHtml="true" compressCSS="true" compressJavaScript="true" compressPage="true" compressWebResource="true" compressThirdParityScripts="false">
<excludeTypes></excludeTypes>
<excludePaths></excludePaths>
</CompressorSettings>
</Miron.web>

i have set the reflectionAlloweded="false" as i will be using shared hosting and in the aspx pages header i am doing this

<script type="text/javascript" src="Scripts/jslib.axd?d=~/Scripts/CollapsiblePanel1.js"></script>
<script type="text/javascript" src="Scripts/jslib.axd?d=~/Scripts/CollapsiblePanel2.js"></script>

so my question is that is it good enough to apply compression on script files and other compressions which are set to true

and my second question is that ScriptResource.axd files only download on client side only once for whole website or do they download for each page so tell me some what about them plz..

Miron il

Friday, May 30, 2008 2:07 PM

Miron

@Adeel,
I didn't fully understand your firs question, about your second one, ScriptResource.axd are been served by another handler
provided my Microsoft.

Ch. Adeel sa

Friday, May 30, 2008 6:38 PM

Ch. Adeel

Hi!
well i have provided the code which i am applying in my application so i was just asking you that am i applying correctly?

Hemant in

Sunday, June 01, 2008 9:42 PM

Hemant

Hi Again,
In one particular location of my ASP.NET 2.0 web page, the RemoveWhiteSpacesFilterStream is rendering my content as

<divclass="metoo" _moz-userdefined="" style="">
<span>
<a href="http://apps/metoo.aspx?pid=83" target="_parent"> Me Too!</a>
</span>
<span class="q">some text between the span element</span>
</divclass="metoo">

you can see that there is no space between the div and the attribute class. If i set optimizeHTML = "false", things are working correctly. I think the regular expression is removing the needed space. Can you help me out here.

Regards,
Hemant.

Miron il

Sunday, June 01, 2008 10:16 PM

Miron

@Hemant,
Thanks for the info.
Until I will have time to work on that, leave the optimizeHTML = "false". The different is no so big.
I will let you know if I found the problem as soon as I can.

.NET slave

Thursday, June 12, 2008 7:46 AM

trackback

Trackback from .NET slave

Compress WebResource.axd in ASP.NET

Dave ca

Wednesday, July 09, 2008 4:58 AM

Dave

This is a great control!

When I enable: <add name="PageCompressionModule" type="Miron.Web.MbCompression.PageCompressionModule, MbCompression, Version=1.0.1.5"/>

I get:

"Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression."

Miron il

Wednesday, July 09, 2008 12:38 PM

Miron

@Dave,
I guess it something with the supported encoding header sent by your browser.
I'm this days working on that issue to improve it. Keep truck the changes in http://www.codeplex.com/MbCompression
What enviroment and browser are you using?

DotnetShadow au

Wednesday, July 09, 2008 7:50 PM

DotnetShadow

Hi there,

Great code here,

How do you combine javascript and css into one request using your tool? Also is the technical document up to date with your latest release that has 3rd party scripts update?

Thanks for your time and effort

Miron il

Wednesday, July 09, 2008 11:28 PM

Miron

The readme.txt file inside the release archives is up to date for the release code.
However, the current release (1.0.1.5) is not supporting the combining, only the next release that will go out soon.
I will post here when it will be released.
Feel free to suggest new features in the link: www.codeplex.com/MbCompression/Thread/List.aspx

DotnetShadow au

Thursday, July 10, 2008 1:19 AM

DotnetShadow

Thanks for the reply,

I actually was using this module before maybe there might some stuff in there you might want to use:

www.codeproject.com/KB/aspnet/httpcompression.aspx

Regards DotnetShadow

Orry il

Wednesday, July 23, 2008 5:02 AM

Orry

Kudos Miron,

Kol Hakavod!! Very nice work. Another Telerik customer on the verge of happiness... Smile

tarun in

Wednesday, July 30, 2008 6:13 PM

tarun

in ie6 menu is not working.

Miron il

Thursday, July 31, 2008 6:51 AM

Miron

@tarun,
Do you get a Javascript error ? is it comes from Webresource.axd, or from normal js file?
Thanks for share it. I guess removing the condition that exclude IE6 from the compression needs to come back.
follow the changes in http://www.codeplex.com/MbCompression

tarun in

Thursday, July 31, 2008 10:20 PM

tarun

Hi Miron
thank you for replaying. i m not getting any error.actually mouse over is not working for menu.
can u pls suggest me what will be the problem?

tarun in

Friday, August 01, 2008 5:39 PM

tarun

hi Miron, error is resolved. div is overlaping so i change css for div tag.i place menu in that division tag. now its working in ie6. and all other browser it is working now.

thank you.

Balaji in

Sunday, August 10, 2008 10:09 PM

Balaji

Hi Miron,

Does it compress ScriptResource.axd as well ? How much percentage of compression is employed for WebResource.axd[Original:30KB - After Compression: ?] file ?

Miron il

Sunday, August 10, 2008 11:18 PM

Miron

@Balaji,
To compress ScriptResource.axd you can just use the build-in mechanism provided by the MS-AJAX framework.
About the compression rate, I guess you have to try and find it your self.

Balaji in

Sunday, August 10, 2008 11:43 PM

Balaji

Thanks mate.

Balaji in

Wednesday, August 13, 2008 9:12 PM

Balaji

Hi Miron,

I followed your instructions and added MbCompression.dll into my bin folder. I then added "<add name="PageCompressionModule" type="Miron.Web.MbCompression.PageCompressionModule"/>" into my web.config by following your instructions. when i run the application i get an error page that says "Parser Error Message: Could not load type 'Miron.Web.HandlersAndModules.PageCompressionModule'. (G:\anytimerooms\web.config line 52)" i am not uploading my site to the server. i get this on the localhost. why is this ? i did not add any other info into web.config too.

Balaji in

Wednesday, August 13, 2008 9:28 PM

Balaji

wht is the purpose of cachingStorage="FileSystem", autoMode="true", scriptsVersion="1",cssVersion="1" in web.config in compressor settings

Balaji in

Wednesday, August 13, 2008 9:34 PM

Balaji

why do i get a error that says 'Cannot resolve symbol 'Miron'' in my web.config'?

Miron il

Wednesday, August 13, 2008 10:21 PM

Miron

@Balaji
Follow the instructions in the Readme.txt fife withing the source code.
You must add a new sectionGroup in the web.config
cachingStorage="FileSystem" means that first time a page load, the compression module/handler loading the external files (js/css) compress them, minify, combine them (if configured) and save the results as a file and next time it will be served from that file directly.
autoMode="true" means you don't need to change any thing in your code (only the web.config) for the compression to work. Only if you want it to combine files you will need to do it manualy (see readme file).
The propose of the scriptsVersion="1",cssVersion="1" is to force the clients to update the css & js content in it's cache.
You want the client to get new js file and update it's local cache - change the number in scriptsVersion="1" (the same for css)

Balaji in

Wednesday, August 13, 2008 11:28 PM

Balaji

Thanks miron. wht is the purpose of including the machine key when reflection is not supported on hosting servers ? can i just include the machinekey given in your quickstart example file ?

Miron il

Wednesday, August 13, 2008 11:41 PM

Miron

The original Webresource handler is using reflection to encrypt/decrypt the webresource url.
When reflection is not allowed for users code (usualy on share hosting) we can't decrypt that url, so I used some tricky stuff using faked membership class that can decrypt that url. For get it work right, it is better to use 'hard coded' machinekey.
You can use my machinekey or just generate one time one for your site. (you can use this site: www.orcsweb.com/articles/aspnetmachinekey.aspx)

DotnetShadow au

Thursday, August 14, 2008 4:18 PM

DotnetShadow

Hi Miron,

I wrote to you a few weeks ago and wrote:

"The readme.txt file inside the release archives is up to date for the release code.
However, the current release (1.0.1.5) is not supporting the combining, only the next release that will go out soon. "

I know you must be busy but I was wondering if there is a new version yet that combines scripts as well?

Regards DotnetShadow

Miron il

Thursday, August 14, 2008 10:16 PM

Miron

@DotnetShadow
A new release will be soon. By now, feel free to download the latest code in the 'Source code' tab and send me some feedback that will help me before the release.
Note that it will support manual combining and not 'blind' combining and it will stay like this on purpose.
In my opinion,'Blind' combining have more drawbacks than benefits. I think the developer should decide by himself what combine with what and where.

Nariman ca

Monday, August 25, 2008 3:40 AM

Nariman

Hi there; I've spent the morning reading the two blogs (yours and Mads). Do these solutions presume that IIS HTTP Compression is not available? JS/CSS/AXD/etc. can all be gzipped at that level, with any gains attributable to whitespace 'minifying' files ahead of time rendered inconsequential. Short of consolidating AXD requests (which I haven't seen an elegant solution for that works in all cases), I'm not sure what the value-add is here...It doesn't really seem like enterprise deployments of .NET stand to benefit from these libraries, but please correct me I'm missing something? (Side-stepping any gains realized from extended client caching...)

Miron il

Monday, August 25, 2008 3:54 AM

Miron

If you have full access to the IIS settings, You can get the compression benefits without any library.
But, what if your site is hosted on share hosting and you have no access for the IIS settings?
Another benefits are minifing and combine files. Those 2 benefits can't be done by the IIS itself.

Nariman ca

Monday, August 25, 2008 4:44 AM

Nariman

Perfect. That's what I expected - i.e. not applicable to enterprise deployments.

The value-add of a trivial (whitespace-based) minifying algorithm prior to IIS compression should be negligible, I think.

And I'd definitely be interested in combining all AXD requests, but as you've pointed out, this needs to be done carefully.

(I think this is almost a guranteed addition in the next release of System.Web).


Thanks.

Miron il

Thursday, August 28, 2008 7:13 AM

Miron

@Dave,
The error you mentioned shouldn't happen again, since the code parse the "Accept-encoding" header as described by section 14 of RFC2616.
Please get the latest version (not release) and confirm that it works fine? So I can go
for the next Beta version ?

Tung au

Monday, September 08, 2008 11:32 AM

Tung

Hi Miron,
We have found a bug on the html minification.
This code: ... class="vehicle vehicle1"...
become: ... class="vehiclevehicle1"...

which breaks the layout of the website. It is a rare case, only happens to a few pages (out of hundreds) in our website.

Miron il

Monday, September 08, 2008 2:10 PM

Miron

@Tung,
Thanks for reporting the bug.
This is know bug, and if you use the release version (1.0.1.5) it is recommended to disable this feature by setting the attribute:
optimizeHtml="false".
In the coming release, this feature has been removed since the disadvantages are bigger than its advantages.

Tim-Stanley.com

Wednesday, September 24, 2008 8:27 AM

trackback

Trackback from Tim-Stanley.com

Using Cache And Compression For Performance

Chase ca

Wednesday, October 08, 2008 4:34 PM

Chase

Hello Miron
I have been posting as much info as possible at www.codeplex.com/.../View.aspx?WorkItemId=2408 regarding my issue with your app. This app looks to be really REALLY incredible but I just can't seem to figure it out. Any direction you might have would be great!!!.

Matias ar

Tuesday, October 14, 2008 3:15 AM

Matias

Hi Miron:

First of all, i would like to thanked you for share your
knowledge, it's a very helpful article, and it's really help me to improve my knowledge about this topic .Now i would like to ask you if you had the oportunity to try it with the ultrawebgrid of infragistic? My problem is the following i've added the tag in the webconfig as you suggest in the readme.txt file for the compression of the webresource.axd, but the only problem that i've found, when i make a search in my page it brings the result that match with the search term but the ultrawebgrid never bind the results and stay in blank. Any suggestion about it? It doesn't throw and exception.

Dave us

Friday, October 31, 2008 1:16 AM

Dave

Hi,
I am having an issue with mbcompression working with a webservice... I keep getting undefined errors when I try to call the web service from javascript, it works when the compressions automode is set to off. Any Ideas? Everything else works great!

Henry us

Wednesday, December 10, 2008 8:40 AM

Henry

Hi Miron,

Have encourage one problem with component when page has inline JavaScript code in it with a comment. When compression is done it places valid code within that comment, i.e. if have next code on the page
<script type="text/javascript">
$(document).ready(function(){
// reshow all hidden items
$("#modNewsHighlight .jcarousel-item div"Wink.show();

if (newsHighlightCarousel != null)
{
newsHighlightCarousel.startAuto(9);
}

</script>
The compressed version will keep comment and compression code after the comment will end up within that comment line, i.e.
// reshow all hidden items $("#modNewsHighlight .jcarousel-item div"Wink.show();

Could you assist? Unless I'm missing the settting that allows to remove the comments from the code...

Thank you,
Henry

Miron il

Thursday, December 11, 2008 12:02 AM

Miron

@Matias, @ Dave & @Henry,
All the problems you described fixed and suppose to be fine.
Download the latest source from the 'Source Code' tab, compile it and use the dll from the Bin directory instead of the on you downloaded before.
Please let me know if it works for you.

@Chase,
I'm still waiting for you to send me some source code with your problem, so I can investigate it.

renantech ph

Thursday, January 15, 2009 2:26 PM

renantech

Very nice tips thanks for sharing.. Very informative..

Stonehenge Tours gb

Sunday, January 18, 2009 9:39 PM

Stonehenge Tours

I had the same problem in IE6 although appears to work fine in FF.

Mandar us

Thursday, January 22, 2009 7:44 AM

Mandar

Hi Miron,

Couple of things..

1. Needs modification for "mironabramson.com/.../...Implementation.aspx" as the namespace has changed . Miron.Web.HandlersAndModules to => Miron.Web.MbCompression. Users downloading dll still may refer the above link .. which I did.

2. I am using ajax and ajax toolkit for asp.net 2.0 .. also I have disabled Page viewstate.
I get following error while I tried to run the web app


[HttpException (0x80004005): Server cannot append header after HTTP headers have been sent.]
System.Web.HttpResponse.AppendHeader(String name, String value) +3296862
Miron.Web.MbCompression.ResponseUtil.SetEncodingType(HttpResponse response, String encoding) +53
Miron.Web.MbCompression.PageCompressionModule.OnPostReleaseRequestState(Object sender, EventArgs e) +474
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Well I also tried to clear contents and headers from response.. but no much help.


Appreciate you help.

--Mandar

Miron il

Thursday, January 22, 2009 10:06 AM

Miron

@Mandar ,
You right. The implementation page needs to be change. Soon, when I will have time, I will release new version, and I will update that page.
Is the error you described happen with the last source code (not the release version) ?
If so, can you send me some code that I can exam it?

Mandar us

Friday, January 23, 2009 2:31 AM

Mandar

Hi Miron,

I am using dll from download section.

MbCompression.dll
Version 1.0.1.5
Created: Friday, May 09, 2008, 5:05:04 PM

As I mentioned earlier I am using ASP.NET 2.0 and AJAX toolkit (AJAX Extensions 1.0)..

My guess is the errors are caused due to Ajax's partial calls..

--Mandar

Miron il

Friday, January 23, 2009 8:28 AM

Miron

@Mandar,
Download and use the DLL from the last source in the source code tab.
The Ajax issue was solved.

Original London Tour gb

Sunday, January 25, 2009 9:43 PM

Original London Tour

Hi Mandar, Thanks for this its really very good. I would definately like to know when you release the new version and will await your update. Thanks.

Yovav us

Wednesday, January 28, 2009 1:36 AM

Yovav

Here is another solution - implementaion is very easy and flexible,

micromighty.com/.../HTTP_Compression_Module.aspx

micromighty.com/.../HTTPCompressionModule.aspx

Hectic Capiznon bloggers 2009 ph

Friday, February 13, 2009 6:19 PM

Hectic Capiznon bloggers 2009

Wow this was a very informative post..thank you very much for providing this..

Yevgeni Frolov

Tuesday, February 17, 2009 6:12 AM

trackback

Trackback from Yevgeni Frolov

Web Performance: AXD files compression.

Kampanye Damai Pemilu Indonesia 2009 id

Friday, February 20, 2009 11:21 AM

Kampanye Damai Pemilu Indonesia 2009

great info, hopes someday I can understand bout this

car accident attorney in fontana us

Thursday, February 26, 2009 5:31 AM

car accident attorney in fontana

Thanks for breaking down this information. i've been trying to figure out the new compression module.

Kampanye Damai Pemilu Indonesia 2009 us

Wednesday, March 11, 2009 8:36 PM

Kampanye Damai Pemilu Indonesia 2009

thanks for this info..

Joy gb

Monday, April 06, 2009 10:15 PM

Joy

Hi Miron

Do you have any idea the following WebResource.axd files cannot be minified?
1. The WebResource which contains function WebForm_PostBackOptions(...) (pretty sure this is the main Ajax .js file)
2. The WebResource which contains function WebForm_FindFirstFocusableChild(control)

I am using Ajax 2.0 Framework.

Also currently I am working on the combination of WebResource.axd files. Please let me know if you are interested.

Miron il

Tuesday, April 07, 2009 4:22 AM

Miron

@Joe,
Using the latest code from the source code tab (not the release) those files can be compressed and minified.
I always interest on new things and idea.
I will be glad to hear ideas and improvements.

Joy gb

Wednesday, April 08, 2009 7:59 PM

Joy

Miron

Can you send me the short version of the module which includes only the Webresource.axd compression?

There are several articles about combining Webresource.axd files. One of the articles I think quite helpful is www.codeproject.com/.../fastload.aspx

However, yes, as you said, it also has the problem of not caching the request (or double it). The technique is pretty much similar to combining .js and .css files in the sense that it tries to send a short version of the URL with parameters.

The solution that I am thinking here is to combine that and the current MbCompression module to make one single request to WebResource.axd files and compress the response to minimum.

I am happy to work with you on this. Just please let me know. You've got my email above.

Miron il

Thursday, April 09, 2009 10:51 PM

Miron

Hi @Joy,
You can download the full source code from Codeplex: http://www.codeplex.com/MbCompression

Joy

Tuesday, April 14, 2009 10:16 PM

Joy

Miron,

Can you send me your email? I tried the contact link above to attach a demo but it didn't work.

Anonymous us

Thursday, April 16, 2009 12:06 AM

Anonymous

Miron, thank you for taking the time to figure this out. Can you please proof read your artical for spelling and grammatical errors. It is very difficult to read when every third word is spelled incorrectly.

Thanks.

Miron il

Thursday, April 16, 2009 3:14 AM

Miron

Sorry for my English. It is not my native language.
I tried to correct the spelling in the article.

Missionary Travel Agency ch

Friday, April 24, 2009 1:21 AM

Missionary Travel Agency

In one particular location of my ASP.NET 2.0 web page, the RemoveWhiteSpacesFilterStream is rendering my content as

<divclass="metoo" _moz-userdefined="" style="">
<span>
<a href="http://apps/metoo.aspx?pid=83" target="_parent"> Me Too!</a>
</span>
<span class="q">some text between the span element</span>
</divclass="metoo">

free ebook us

Saturday, April 25, 2009 7:36 AM

free ebook

Thanks for the great reference post.

jimmy choo ma

Saturday, April 25, 2009 11:17 PM

jimmy choo

The solution that I am thinking here is to combine that and the current MbCompression module to make one single request to WebResource.axd files and compress the response to minimum.

radioblende tn

Sunday, April 26, 2009 4:59 PM

radioblende

Great solution choosed.what I did was to create an HttpModule, using the event Pre Request Handler Execute that is one step before the handle action, do my stuff here, and then end response and jump over the hander step.Thanks for sharing.

kmg us

Tuesday, April 28, 2009 4:17 AM

kmg

I ran through the readMe with the source version and am still getting the message "Parser Error Message: Could not load type 'Miron.Web.HandlersAndModules.PageCompressionModule'. "

do you have a sample web.config with all the settings in it?

Thanks!

Miron il

Tuesday, April 28, 2009 9:09 PM

Miron

@kmg,
The source in this post is old and not up-to-date.
Please download the source from http://www.codeplex.com/MbCompression
and follow the implementation instructions in the readme.txt file within the source

Joy gb

Thursday, April 30, 2009 2:47 AM

Joy

Miron

Any luck with improvement? Haven't heard any news from you yet.

Niaphron fr

Sunday, May 03, 2009 4:10 PM

Niaphron

Hi miron,

When i use your MbCompression in my VS 2008, the source code :
<script type='text/javascript' src='Scripts/jslib.axd?d=~/js/a.js,~/js/b.js,~/js/c.js,~/js/d.js'></script> work perfect ;-)
And page compression work perct !

But when i put it on my on IIS 7.0 server (Windows Server 2008), it's not work. :-(
Threre is a particular config IIS to use your MbCompression ? I have got direct access to configure IIS

Casper

Monday, May 04, 2009 10:17 PM

Casper

Hi, Miron
i've got a question: I add
<sectionGroup name="Miron.web">
<section name="CompressorSettings" type="Miron.Web.MbCompression.SettingsConfigSection"/>
</sectionGroup>
in configSections, and when i add records to httpHandlers, no problem, but when i add records to httpModules
<add name="PageCompressionModule" type="Miron.Web.MbCompression.PageCompressionModule"/>
<add name="WebResourceCompressionModule" type="Miron.Web.MbCompression.WebResourceCompressionModule"/>
vs underlines it, saying Cannot resolve..... pleeeease tell me, what i'm doing wrong??

Miron il

Wednesday, May 06, 2009 4:46 AM

Miron

@Casper,
Download the latest source from the Source Code tab and follow the readme.txt file in the compression project and the example.

German Translation dz

Wednesday, August 05, 2009 12:50 AM

German Translation

Hi gays,
Hi Miron,

I am using dll from download section.

MbCompression.dll
Version 1.0.1.5
Created: Friday, May 09, 2008, 5:05:04 PM

As I mentioned earlier I am using ASP.NET 2.0 and AJAX toolkit (AJAX Extensions 1.0)..

My guess is the errors are caused due to Ajax's partial calls.. ?

Miron il

Wednesday, August 05, 2009 12:54 AM

Miron

See my last answer to @Casper

Lance

Tuesday, August 11, 2009 2:27 AM

Lance

Hi Miron
thank you for replaying. i m not getting any error.actually mouse over is not working for menu.
can u pls suggest me what will be the problem?

Madmat us

Tuesday, August 11, 2009 8:47 AM

Madmat

Hi Miron,
I have followed all the steps defined in the ReadMe file. I am getting the error:
Could not load type 'Miron.Web.HandlersAndModules.PageCompressionModule'
I am jotting the steps that I did so that you can tell me where I was wrong:

--Copied the MbCompression.dll to Bin
--added the : <sectionGroup name="Miron.web">
<section name="CompressorSettings" type="Miron.Web.MbCompression.SettingsConfigSection"/>
</sectionGroup>
--added to existing modules
<add name="PageCompressionModule" type="Miron.Web.HandlersAndModules.PageCompressionModule"/>
--Added the <Miron.web> section

One more question is , does this compress the Scriptresources too?

Miron il

Tuesday, August 11, 2009 9:38 AM

Miron

@Madmat, you are mixing versions.
Download the latest source code from the "Source Code" tab from:
mbcompression.codeplex.com/.../...ableCommits.aspx
And follow the example in the 'QuickStart' web project.
MbCompression does NOT compress ScriptResource since 'ToolkitScriptManager' from the AjaxControlToolkit does it very well.

Fede us

Thursday, October 08, 2009 3:17 AM

Fede

Hi, i can not combine anything. it works. i can see the jslib.axd handling my js. but they doesn't combine.
Also i use a framework (dotnetnuke) that include JS in the Body, is impossible to auto combine them?

anyway CSS are in the header, and they doesn't combine also
what im doing wrong, it compress and minify. but doesn't combine
automode is set to true

the module is working in www.mcjuegos.com now, you can check it

this are the settings

<CompressorSettings compressCSS="true"
reflectionAlloweded="true"
compressJavaScript="true"
compressPage="true"
compressThirdParityScripts="true"
combineCSS="true"
combineHeaderScripts="true"
compressWebResource="true"
minifyContent="true"
cachingStorage="OutputCache"
autoMode="true"
scriptsVersion="1"
cssVersion="1">
<excludePaths>
<add key="~/DontCompressMe.aspx"/>
</excludePaths>
<excludeFromMinifyPaths>
<add key=""/>
</excludeFromMinifyPaths>
</CompressorSettings>

Thiago Burgo br

Sunday, October 18, 2009 2:36 PM

Thiago Burgo

Hi Miron,

Congrats for your great work.

I have a problem, after add MbCompression in my project i had a problem with Exception engine, the yellow page (with exception summary) disappears, the brownser cannot decompress the page. Other problem happens when activate Outputcache, the brownser render a crazy content, Can you help me?


Thank you.

waggi us

Wednesday, October 21, 2009 3:20 PM

waggi

Great post

ihsan tr

Friday, November 13, 2009 8:51 PM

ihsan

Hi Miron,

i follow your blog and this is a great article like others.. Yesterday i downloaded your project's latest version.
When i open QuickStart sample in VS2005 to run it, it crashed in default.aspx (Microsoft JScript runtime error: 'swfobject' is undefined).
Also MbCompression CS Project can not build, i think something is missed or unfinished for next release??
i m using vista, iis7,ie7 or ff3.5, VS2005 and 3.5 components are included..

Thank you..

Miron us

Saturday, November 14, 2009 4:01 AM

Miron

@ihsan,
I checked again, I downloaded the latest version from mbcompression.codeplex.com/.../...ableCommits.aspx
and it run fine. No errors. Nothing is missing there.

ihsan tr

Sunday, November 15, 2009 10:33 PM

ihsan

Yes you are right, there is not unfinished code..
but these code lines does not work on .net2.0 and a simple change below;

in WebResourceCompressionModule.cs line 256
3.5
string[] strArray = assemblyName.Split(new[] { ',' });
2.0
string[] strArray = assemblyName.Split(new char[] { ',' });

and
in EncodingManager.cs line 118
3.5
string[] headersParts = _RequestHeader.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
2.0
string[] headersParts = _RequestHeader.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

ok..
but still QuickStart web site has got a javascript error ..
firebug console output;

swfobject is not defined
swfobject.embedSWF("test.swf", "... "120", "9.0.0", "expressInstall.swf"Wink; default.aspx (line 11)
jQuery is not defined
$("tr:visible",table.tBodies[0]).filter(...g Zebra widget",time);}}});})(jQuery); jslib.ax....6.js&v=1 (line 49)

where can be problem? if you can show me some way, maybe i can find the problem..

thank you..

pankaj us

Tuesday, November 17, 2009 12:54 AM

pankaj

Hi there,

Very Nice library....i am using it for compression of js,css,WEbResource.axds and ASP.Net pages but i am having a problem with images.....

after applying the compression everything is working fine......no broken css, or js and webresource is also getting compressed along with ASP.NEP pages but strangely all the dynamic images have dissapppered.........the rest of the images i.e in the App_themes folder, and images folder are getting loaded....but when getting a image dynamically( such as to show in a datalist) it gives error code 500...

here is the error msg

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'MbCompression' or one of its dependencies. The system cannot find the file specified. (C:\whb\Sites\18448\Web\web.config line 81)

Source Error:


Line 79: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 80: <!--<add name="HttpCompressModule" type="DC.Web.HttpCompress.HttpModule,DC.Web.HttpCompress"/>-->
Line 81: <add name="WebResourceCompressionModule" type="Miron.Web.MbCompression.WebResourceCompressionModule, MbCompression"/>
Line 82: <add name="MbCompressionModule" type="Miron.Web.MbCompression.MbCompressionModule, MbCompression"/>
Line 83: </httpModules>


Source File: C:\whb\Sites\18448\Web\web.config Line: 81

how do i solve this...........please it is urgent....

i have also posted this as an issue at CodePlex

Satish my

Thursday, December 10, 2009 1:12 AM

Satish

Hi Miron,

Have you tested this library in Mono .. if so will you be able to post web.config settings for the same .

Thanks
Satish

RRaveen us

Thursday, December 10, 2009 1:46 PM

RRaveen

Hi,

nice work, i download your sample code, but could not see the compress sample web page. there are 3 aspx files, same file size even if i disable compression. please advice to me which the file you have compressed. and add some testing result as well using ySlow or Firefug.

thank you

Jonas lt

Sunday, March 07, 2010 10:55 PM

Jonas

Hi Miron,

At first thank you for this library.
I get error:
Content Encoding Error "Content Encoding Error " for firefox
Could be it related to other compression/manipulation modules like Snapsis PageBlaster for DotNetNuke sites?
If so, should we place you module in the end of <httpmodules> section?

Thanks

Kind Regards,
Jonas

chai my

Tuesday, March 09, 2010 12:29 AM

chai

when using compressPage="true" and aspx page output caching together, cached html content will be gzipped again, causing erroneous output on browser window. is there a way to prevent this?

Miron il

Thursday, March 25, 2010 9:09 PM

Miron

@Fede,
Nice site Smile
For the css to be compressed, the must be in the same directory...

Miron il

Thursday, March 25, 2010 9:45 PM

Miron

@Chai,
You have to exclude those files from been compressed.

Miron il

Thursday, March 25, 2010 9:46 PM

Miron

@Jonas ,
Try the latest version I uploaded. The bug should be fixed.

Miron il

Thursday, March 25, 2010 9:48 PM

Miron

@Stish,
I havn't tested the library in Mono.
I will be glad if someone will do and report me the results and changes in code if needed

Miron il

Thursday, March 25, 2010 9:49 PM

Miron

@ihsan ,
Thanks for the suggestions. I uploaded the fixes.
I also fixed the js errors.

Miron il

Thursday, March 25, 2010 9:50 PM

Miron

@Thiago ,
Get latest version of the code.
The bug was fixed.

sonnerie portable gratuite us

Friday, April 16, 2010 1:24 PM

 sonnerie portable gratuite

This article gives the light in which we can observe the reality. This is very nice one and gives in depth information. Thanks for this nice article. Good post.....Valuable information for all.

dot net chat us

Sunday, April 18, 2010 10:29 PM

dot net chat

Thank you for a great piece of info. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week and it is extremely helpful for me.

Medical Tourism IN India us

Monday, April 19, 2010 5:47 AM

Medical Tourism IN India

fully understand your firs question, about your second one, ScriptResource.axd are been served by another handler
provided my Microsoft.

Kids Games

Sunday, April 25, 2010 4:24 PM

Kids Games

This is a nice site you have here, information is carefully written and well-explained. I have been learning myself on .Net a while ago but haven't really worked in a company. Thanks for the info you posted here, it is a big help to everyone who browses the internet and researching. Good job!

phone answering service us

Thursday, May 13, 2010 11:27 PM

phone answering service

Hey thanks for sharing. excellent read. I will definitely forward to my colleagues.

zoya nail polish us

Friday, May 14, 2010 8:21 PM

zoya nail polish

I am happy to find so many useful information here in the post, thanks for sharing.

Gadgetter us

Saturday, May 15, 2010 2:15 AM

Gadgetter

very good idea dude,Do u have another blog?? i want to read Tong Regards

guaranteed bad credit loan

Sunday, May 16, 2010 11:58 PM

guaranteed bad credit loan

there are a lots of blog available on that theme but your best so far...that’s why I am commenting here

Simulateur De Pret Auto us

Wednesday, May 19, 2010 12:25 PM

Simulateur De Pret Auto

Really impressed! Everything is very open and very clear explanation of issues. It contains truly information. Your website is very useful. Thanks for sharing. Looking forward to more!

piyush group in

Friday, May 21, 2010 10:11 PM

piyush group

nice post i had bookmarked your blog, feel free to visit my blog at


batu permata us

Sunday, May 23, 2010 5:00 PM

batu permata

WebResource.axd, that became very large (specially when using AJAX) are break down for unknown reason when you try to compress them that way. That result is you will not compress them, and your client will download big files that contains js or css (sometimes of 70kb and even more)

beijing tours

Sunday, May 23, 2010 9:29 PM

beijing tours


your site impresses me with neat structure and apprearance, always like site that shares useful info...

web hosting mumbai in

Sunday, May 23, 2010 11:17 PM

web hosting mumbai

nice post i had bookmarked your blog end .i had very much like this

Addiction Treatment us

Monday, May 24, 2010 2:22 AM

Addiction Treatment

Its a nice comment.I love reading it in detail and bookmarked it.I found some real value in the content.Loved it.

cara meninggikan badan us

Monday, May 24, 2010 3:13 PM

cara meninggikan badan

I started to make tests and to play with WebResources files. Only WebResources that contains 'text' content (css, js, text) can be consider as compressible. Images are not.

Sell Junk Car us

Thursday, May 27, 2010 3:27 PM

Sell Junk Car

I am bookmarking this post. Its Awesome.