Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does URL Rewriting block IIS's static file caching?

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?

like image 837
Ugur Catak Avatar asked Feb 24 '13 15:02

Ugur Catak


People also ask

What does URL rewriting do?

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.

Is URL rewriting safe?

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.

What is the use of URL Rewrite in IIS?

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.

What is the difference between routing and URL rewriting?

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.


1 Answers

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.

like image 118
Adam Caviness Avatar answered Sep 22 '22 01:09

Adam Caviness