- Prerequisites
- Getting Started
- Upgrade V2 to V3
- Operational Summary
- Distributions
- Automatic Data Updates
- Constants
- Web Applications
- trie matching
- Image Optimiser
- Passing Properties To Client Side
- Client Side Overrides
- User Performance Monitoring
- Offline Applications
- Accessing Metadata
- SQL Server
- IIS Modification
- Log Troubleshooting
- Reference
- Native Code
- Examples And Questions
IIS Modification
Caching and Compression within IIS
Two common and easy ways to increase website performance is to use caching and compression to ensure a minimal amount of bandwidth is consumed.
To make sure that the browser caches correctly the Vary http header is used. This is used not just by the browser, but also by servers in between (such as ISPs) to determine if content is current. For instance, if the Vary header is User-Agent, ISPs will know that content may change depending on a device's user agent so it should give cached content to a device with a new user agent. This practice is recommended by Google as it also helps with their indexing.
However, when both compression and caching is used in IIS the compression module overwrites the entire Vary header with 'Accept-Encoding', removing all of the intelligence that could previously be applied to a cache. This effectively gives IIS users a choice of compression or caching.
Fixing the Vary Header
Eraz Benari and his team at Microsoft have now released an official fix for this problem. You can download the patch here . If you have already installed our previous fix, it is advised to uninstall it completely and revert to the official solution.
51Degrees, together with Erez Benari at Microsoft, has developed two native modules for IIS that restores data stripped from the Vary header. Builds and source code for the modules can be found on our Codeplex page .
These modules work by intercepting the Vary header in the IIS pipeline before compression has occurred, and then putting it back after compression has finished. Two modules are required for this as it is the only way in IIS to do something before and after compression.
- To install, you first must be sure if your server is 32 or 64 bit. Most servers are 64 bit. You should use the specific DLLs for your system's bitness.
- Navigate to '%windir%\System32\inetsrv'. Copy the DDLs straight into this folder.
- Open IIS in administrator mode. From the root server pane you should navigate to modules.
- You should see a list of native and managed modules currently installed on the server. On the right hand side there should be the Action Pane. Click 'Configure Native Modules' to add the modules.
- This should open a dialog box pictured below. If you do not see the register button close IIS Manager and open it again in administrator mode.
- Click Register. You will be prompted for a name and path to the DLL. The name can be anything, but it should be something you will recognise later. This article uses 'CompressionPreProcessor' and 'CompressionPostProcessor'. The path is the path to the DLLs copied into '%windir%\System32\inetsrv' earlier. Both DLLs will need to be registered.
- Click OK (making sure both modules are checked to show they're enabled).
- Now click on 'View Ordered List', also in the action pane. The order is important, we want the CompressionPreProcessor module just before compression, and CompressionPostProcessor just after compression. This way we interfere with the IIS pipeline as little as possible. Use the blue up and down arrows on the side to move both modules in position. CompressionPreProcessor should be just below the Compression and CompressionPostProcessor should be just above, like pictured below.
- You should now see webpages from this server using the Vary header as originally intended.
How it Works
The preprocess module saves the contents of the Vary header into a temporary header (named fod_vary_store). This is then read and placed back into the Vary header by the post process module. The temporary header is deleted. The post process also appends the header values left by the compression process. This ensures that devices which don't support compression aren't served compressed content from a cache.