If I activate IIS Rewrite module File Cache Hits counter does not increase.
I'm tracing the hits by Performance Monitor (perfmon.exe / Web Service Cache/File Cache Hits)
If I deactivate the rewriting "File Cache Hits" increase normally according to IIS caching algorithm.
Requested file is static html file in both two cases.
Does URL Rewriting block IIS's static file caching?
The concept of URL rewriting is simple. When a client sends a request to the Web server for a particular URL, the URL rewriting module analyzes the requested URL and changes it to a different URL on the same server.
While the process of URL rewriting may be understood by IT professionals, many users may be under the impression that any 'Safe' link is indeed safe - although this is often not the case. Thus, URL rewriting can actually have the side effect of increasing the likelihood of users clicking on malicious links.
The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find.
URL rewriting is focused on mapping one URL (new url) to another URL (old url) while routing is focused on mapping a URL to a resource. Actually, URL rewriting rewrites your old url to new one while routing never rewrite your old url to new one but it map to the original route.
The docs state that yes, IIS rewrite can prevent file caching.
Interaction with IIS Output Caching
The URL Rewrite Module controls the IIS output cache behavior in order to:
Optimally utilize kernel mode and user mode output caching of responses for rewritten URLs, thus improving performance of the Web application that uses URL Rewrite Module. Prevent caching of responses, when caching logic may be violated due to URL rewriting. The module controls output caching either by altering certain caching properties or by disabling the caching altogether. The module cannot enable output caching if it has been disabled by IIS configuration or by any other module in the IIS pipeline. The output caching is controlled as follows:
The module always sets the user mode cache setting varyByHeader="HTTP_X_ORIGINAL_URL". This ensures that when user mode caching is enabled the module takes into account the original URL to construct a key for the cache entry.
If a rewrite rule set uses server variables with values that are either constant throughout the life of the process or are derived from the requested URL, the rule set is considered safe for output caching. This means that the URL Rewrite Module will not alter existing caching policy in any way other than setting varyByHeader as described in step
The following server variables, when used in rewrite rules, do not cause any effect on output caching policy:
"CACHE_URL", "DOCUMENT_ROOT", "HTTP_URL", "HTTP_HOST", "PATH_INFO", "PATH_TRANSLATED", "QUERY_STRING", "REQUEST_FILENAME", "REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SCRIPT_TRANSLATED", "UNENCODED_URL", "URL", "URL_PATH_INFO", "APP_POOL_ID", "APPL_MD_PATH", "APPL_PHYSICAL_PATH", "GATEWAY_INTERFACE", "SERVER_SOFTWARE", "SSI_EXEC_DISABLED"
3 . If a rewrite rule set uses any server variable not mentioned in the above list, the rule set is considered unsafe for output caching. This means that the URL Rewrite Module will disable kernel mode caching for all requests whether the request URLs were rewritten or not. In addition, the module will alter the caching policy for user-mode cache by setting the caching property varyByValue to contain the concatenated string of all server variables values used in the rule set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With