Scenario:
At our company, we have enabled httpCompression for our website. This website (call it as master website) and its preview version both are hosted on the same web server. Preview version is used for testing.
The compression settings in the web.config file are
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true"/>
According to this article, compressed files are temporarily saved/cached to the directory specified in the config settings. In my case, it's %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files.
I do not have access to the web server to look at those compressed files. so here are my questions.
How the compressed files are saved/cached or named for different web sites?
Let's say I use same compression directory for both web sites (preview and master). If a user requests a static file from preview website, it is compressed and cached in the directory. Now, another user requests the same file but from master web site. Does the server sends the compressed file of the preview website or it compresses the file again and saves to the directory?
IIS Creates a complex directory structure such as follows:
%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files\(compressionType)\(AppPool)\(WebSite)\compressed files
It will not share the compressed version of the same files across web applications.
So to answer your question, there will be 2 compression versions of the file.
PS - You could have also turned on compression locally on IIS 7.5 and saw this structure locally.
Related
I need to use IIS only for directory browsing. The directory contains ASP.NET Core files and IIS automatically attempts to serve them normally.
Is there a way to force IIS to display all files as static files?
In order to let IIS serves everything as static content, you have to
Keep only Static Files handlers
enable directory browsing
Add mime type for every file. Without that IIS won't know how to serve unknown file type
Disable request filtering to download .config file, bin folder content, etc.
You will find below the corresponding web.config
WARNING : big security issue. Be sure to understand the risk before applying this configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="StaticFiles" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
</handlers>
<directoryBrowse enabled="true" />
<staticContent>
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
</staticContent>
<security>
<requestFiltering>
<hiddenSegments>
<clear />
</hiddenSegments>
<fileExtensions>
<clear />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
I am using the chrome extension YSlow to test my site performance.
I've got F Grade on Compress components with gzip.
There are 15 plain text components that should be sent compressed:
http://localhost:21964/Content/custom/css/blog.css
http://localhost:21964/Content/custom/css/style.css
http://localhost:21964/Content/custom/css/socialize-bookmarks.css
http://localhost:21964/Content/custom/css/prettyPhoto.css
http://localhost:21964/Content/custom/css/flexslider.css
http://localhost:21964/Content/custom/css/colors/color-orange.css
http://localhost:21964/Content/sc2.css
http://localhost:21964/Content/custom/javascript/custom.js
http://localhost:21964/Content/custom/javascript/header.js
http://localhost:21964/Content/custom/javascript/twitter.js
http://localhost:21964/Content/custom/javascript/bra.photostream.js
http://localhost:21964/Content/custom/javascript/jquery.flexslider.js
http://localhost:21964/Content/custom/javascript/jquery.bpopup-0.7.0.min.js
http://localhost:21964/Content/custom/javascript/prettyPhoto.js
http://localhost:21964/css/colors/color-orange.css
Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.
There was a similar post here, But even though I've followed these steps it doesn't compress the traffic.
Steps I've done:
I ticked all the compression settings in the IIS -> Compression.
Activate the Windows Feature "Dynamic Content Compression".
I've added this lines to the web.config:
<system.webServer>
...
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="true"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="true"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
...
</system.webServer>
I am currently using the Developer Server inside the project Properties -> Web -> Servers
The visual studio development server (Cassini) doesn't support gzip compression use IIS or IIS Express.
I have a web app that contains a slide show with about 10 large images (100-200k) images. I've heard of people using gZip http compression to help improve the performance of their websites in the past so I started doing a little research on this. I ended up finding the following web.config snipit that claims to do this:
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>
But after looking at it a little closer this does not appear to do anything for images.
Is using gZip compression for image mimeTypes effective or would I be wasting my time to add it to the above? Can anyone recommend any good strategies for improving the load time of large images?
Side note: Not sure if it makes a difference but the site is hosted on goDaddy.
JPG images, GIF, etc are already compressed formats. Compressing them further isn't going to help much. You should be looking into caching them instead so that the web server returns 304 responses every time a request for the same image is made.
By the way, the Web.config that you posted is not doing compression on images (as it doesn't help).
UPDATE
Configure IIS to return HTTP 304 Status codes on certain file types.
The JPEG format is a compressed format. So no need to compress it again. Think about compressing scripts and css.
Use SquishIt for compressing javascript and CSS.
Try SmushIt from Yahoo to optimise the images
I am using following web.config block to enable static and Dynamic Compression on IIS7, but its not compressing the response.(Verified it through Fiddler)
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/css" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/css" enabled="true" />
<add mimeType="text/javascript" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="true" />
</staticTypes>
</httpCompression>
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
</staticContent>
Yet it is not doing any compression. I had also check the server has static/dynamic compression installed.also tried this how-can-i-get-gzip-compression-in-iis7-working but not working for me. Can anyone help with something new?
I had trouble with getting it working by following snippets of advice on StackOverflow. Here's how I managed it.
First, ensure Dynamic Compression is installed as a feature of the Web Role. Normally, you get a warning in IIS Manager if the module is not installed, but you won't if you've set the web.config manually since it tricks the IIS UI logic.
I then removed all the web.config stuff (as in your question) and set it via the IIS Manager. I did this because on MSDN, an easily-missed comment says:
You can also add wildcard entries for the MIME types. However, you can
set MIME types for the web server level only. For example, to enable
static compression for all MIME types for the default website, first
add wildcard entries for the MIME types for the server level, and then
enable static compression for the default website.
Focus on:
However, you can set MIME types for the web server level only.
So I'm not sure whether all those filters and things really work in the web.config. Personally, it didn't for me - i.e. no Content-Encoding: gzip header.
After I took it all out I had to use IIS Manager, under IIS: Compression, to ensure it was set at the server level and then for the site, I had to remove the tick, apply it, tick it again and reapply it.
I ended up with just <urlCompression doDynamicCompression="true" /> in the web.config, which is a bit strange since I don't care for compressing URLs.
Whatever. I do now have Content-Encoding: gzip in the response headers for my site - so I assume its working.
Could you enable Failed Request Tracing, it should include information about what could be happening, it usually falls into a few buckets, 1) Permissions to generate the compressed file, 2) File is too small to require compression, 3) File is not being frequently enough so it is not being compressed, 4) mimetype issue
http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis7/
My web hosting provider is running IIS7 and I am having loads of trouble to get gzip compression to work properly. Host admins say compression is installed. I can confirm compression using some online checking services but not with others. PageSpeed Firefox add-on also says the site is uncompressed. I am personally sitting behind a Squid proxy but web.config settings should take care of proxy issue. Below is the relevant web.config snippet. Most of it is borrowed from various sites. Any thoughts?
<urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" doStaticCompression="true" />
<httpCompression cacheControlHeader="max-age=86400" noCompressionForHttp10="False" noCompressionForProxies="False" sendCacheHeaders="True" dynamicCompressionEnableCpuUsage="89" dynamicCompressionDisableCpuUsage="90" minFileSizeForComp="1" noCompressionForRange="False">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
This post is about 4 months old, but have you checked if dynamic compression is enabled in IIS? There's an article here on how to do it
http://blog.wassupy.com/2009/08/enabling-dynamic-http-compression-in.html
By default IIS it isn't enabled. Might be worth trying.
Try two this towards resolving this issue:
Try following the case standard for setting booleans in the web.config and use lower case rather than pascal casing.
Try connecting to the site on the server via IIS if your host allows this and check the compression section to see if it is locked.