IIS 7.5 and IIS 8.0 European Hosting

BLOG about IIS 7.5 Hosting, IIS 8.0 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

IIS 8 Netherlands Hosting - HostForLIFE.eu :: Using Outbound Rewrite Rules to Offload Your Content on IIS 8

clock March 10, 2014 09:06 by author Peter

Recently a colleague of mine wrote an article on setting up a CDN (Content Delivery Network). This made me experiment a bit with some IIS 8 settings. It is possible to set up IIS to rewrite all outgoing requests in such a way that your static content (e.g. images, style-sheets, etc) will be downloaded from a separate location. The main benefit of this method is (in my opinion) that it doesn’t requiren any adjustments on your target site. All it requires is some tweaking of your web.config and ofcourse a working CDN.

Outbound rewrite rules are a pretty powerful thing, when used properly. When used incorrectly, they can slow your site down to a screeching halt. Lucky for us, the outbound rewrite rules can be used to filter out specific requests. In this case we will use them to rewrite all outgoing HTML code. We want to search out all static content (in this example .jpg and .png files) and rewrite it on the fly to be downloaded from a CDN. So, first we want to set the proper precondition. Loads of data leaves a webserver, so let’s make sure we only look at the relevant parts of it. We start by setting up a precondition:

<preConditions>

      <preCondition name="CheckHTML"> 

           <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 

      </preCondition> 

</preConditions> 

Now we’re looking at all HTML only it’s time to get even more specific. Outbound rules allow you to filter a tag you want to look for. In this case we assume all images are located in tags. So we can use the following filtering before actually matching it to a pattern:

<rule name="CDN"stopProcessing="false">  
      <match filterByTags="Img" pattern="(https?:\/\/www.(.*)\.(jpg|png))" />  
      <action type="Rewrite" value="http://cdn.{R:2}.{R:3}" />  
 </rule> 

Noticed the ugly regex I used there? Let’s take a look at it:

(https?:\/\/www.(.*)\.(jpg|png))

All this baby does is matching all url’s containing .jpg or .png on the end. So basically it makes sure we catch all outgoing image url’s before they reach the browser. This same regex gives us 3 backreferences. We only need two of them: {R:2} and {R:3}. These contain (in my case) the stripped url (no more http://www.) and the extension. We use these later on to rebuild the url for our CDN. You might want to adjust this regular expression to suit your specific needs.

For me: this one is all I need. Now it’s time for rewriting our url. I can use the backreferences that are given to re-assemble the image location to something that should be working on the CDN. How the data gets there is up to you. I’m only pointing out how you can redirect traffic there ;) After your done, the following can be used in your web.config:

<rewrite> 

      <outboundRules>

          <rule name="CDN" preCondition="CheckHTML" stopProcessing="false"> 

                <match filterByTags="Img" pattern="(https?:\/\/www.(.*)\.(jpg|png))" /> 

                <action type="Rewrite" value="http://cdn.{R:2}.{R:3}" /> 

           </rule> 

           <preConditions> 

                <preCondition name="CheckHTML"> 

                     <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 

                </preCondition> 

          </preConditions> 

      </outboundRules>

</rewrite>



IIS 8.5 Hosting Netherlands - HostForLIFE.eu :: New Features IIS 8.5

clock February 7, 2014 12:06 by author Peter

Internet Information Services (IIS) 8.5 is an extensible web server created by Microsoft for use with Windows NT family. IIS 8.5 is included in Windows Server 2012 R2 and Windows 8.1. This version includes Idle worker-Process page-out, Dynamic Site Activation, Enhanced Logging, ETW logging, and Automatic Certificate Rebind.

IIS 8.5 has several improvements related to performance in large-scale scenarios, such as those used by commercial hosting providers and Microsoft's own cloud offerings. It also has several added features related to logging and troubleshooting. The new features are:

  • Idle worker-Process page-out – a function to suspend idle site to reduce the memory footprint of idle sites. In IIS 8.5, the Administrator has the option of suspending an idle worker process rather than terminating it. A suspended worker process remains alive but is paged-out to disk, reducing the system resources it consumes. When a user accesses the site again, the worker process wakes up from suspension and is quickly available.
  • Dynamic Site Activation – a feature that registers listening queues only to sites that have received requests.
  • Enhanced Logging – Now you can customize the logging to store request headers, response headers and server variables. The customization can be used to get information such as the IP addresses of connecting clients when the network has a load balance.
  • ETW logging – Event Tracing for Windows (ETW) provides application programmers the ability to start and stop event tracing sessions, instrument an application to provide trace events, and consume trace events. Trace events contain an event header and provider-defined data that describes the current state of an application or operation. You can use the events to debug an application and perform capacity and performance analysis.
  • Automatic Certificate Rebind – a feature that detects when a site certificate has been renewed, and automatically rebinds the site to it

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in