Does URL Rewriting block IIS's static file caching?
Asked Answered
A

1

8

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?

Adowa answered 24/2, 2013 at 15:50 Comment(1)
In IIS Manager, go to Modules and Open Feature. On the right, click "View Ordered List". RewriteModule should be near the bottom if it isn't.Rocket
B
2

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:

  1. 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.

  2. 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.

Bern answered 9/4, 2014 at 3:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.