Loading blog entries.. loading

Blogs which referenced tag: [IIS]


URL Rewrite Rules used by WayneYe.com

Written by Wayne Ye  Sunday, October 16, 2011

I've successfully transferred my website to winhost, now the architecture is IIS 7.5 + ASP.NET 4.0 + SQL Server 2008 R2 + HTML5, this blog post is a summary about URL Rewrite Rules used by WayneYe.com.

RESTful URL for blogs

Blog posts are absolutely the soul of a blog website, comparing with blog URL format: "/yyyy/MM/{Blog_Title}", I actually prefer "/Blog/{Blog_Title}", more simpler/shorter, in additional and more important, generally speacking,valuable content is valuable no matter when it was posted, for example, a developer is searching C# covariance & contravariance articles, two articles separately posted on 3/28/2010 and 1/25/2011 won't make ANY difference for this developer.

Now that all my blogs take URI format like: "http://WayneYe.com/Blog/{Blog_Title}", it is so called "Permalink", I must ensure there is no duplicate blog titles (not case sensetive even if I can enable URL case sensitive through IIS manager, it would be quite confuse to the end user), so actually in my backend blog post page I did a DB check for existing blog titiles:)

Here is the Blog URL rewrite config XML stored in my Web.config:

 <rule name="BlogPermalinkRewrite">
    <match url="^Blog/([A-Za-z0-9-_()^%]{1,})$" />
    <action type="Rewrite" url="ViewBlog.aspx?Permalink={R:1}" />

Navigate Links

That's so simply, rewrite to an ASPX page under a matched directory:

 <rule name="NaviAlbum" patternSyntax="ExactMatch">
    <match url="Album" />
    <action type="Rewrite" url="Album/Index.aspx" />
<rule name="NaviVideo" patternSyntax="ExactMatch">
    <match url="Video" />
    <action type="Rewrite" url="Video/Index.aspx" />
<rule name="NaviTags" patternSyntax="ExactMatch">
    <match url="Tags" />
    <action type="Rewrite" url="Tags/Index.aspx" />
<rule name="NaviVisitRecord" patternSyntax="ExactMatch">
    <match url="VisitRecord" />
    <action type="Rewrite" url="VisitRecord/Index.aspx" />
<rule name="NaviAboutMe" patternSyntax="ExactMatch">
    <match url="AboutMe" />
    <action type="Rewrite" url="AboutMe/Index.aspx" />


These three type of URLs are similar, but makes a log of sense to a website comforming REST.

 <rule name="CategoryRewrite">
    <match url="^Category/([A-Za-z0-9-_/]{1,})$" />
    <action type="Rewrite" url="ShowBlogs.aspx?Condition=Category&amp;Cat={R:1}" />
<rule name="BlogTagRewrite">
    <match url="^Tag/(.*)$" />
    <action type="Rewrite" url="SearchTag.aspx?t={R:1}" />
<rule name="ArchiveYearRewrite">
    <match url="^Archive/(\d{4})$" />
    <action type="Rewrite" url="ShowBlogs.aspx?Condition=Time&amp;Year={R:1}" />
<rule name="ArchiveYearMonthRewrite">
    <match url="^Archive/(\d{4})/(\d{2})$" />
    <action type="Rewrite" url="ShowBlogs.aspx?Condition=Time&amp;Year={R:1}&amp;Month={R:2}" />
<rule name="ArchiveYearMonthDayRewrite">
    <match url="^Archive/(\d{4})/(\d{2})/(\d{1,2})$" />
    <action type="Rewrite" url="ShowBlogs.aspx?Condition=Time&amp;Year={R:1}&amp;Month={R:2}&amp;Day={R:3}" />

Define Atom/RSS feeds MIME type

WayneYe.com programmatically generates Atom/RSS feeds in plain XML format, the two XML file exists phisically under Feeds/Atom/Atom.xml and Feeds/RSS/RSS.xml, other then rewrite URL for both, one more important thing to do is override the "text/xml" MIME type to follow the standard:

  1. Atom feeds MIME type should be "application/atom+xml"
  2. RSS feeds MIME type should be "application/rss+xml".

To achieve this needs a little bit more work: intercepting response stream and overriding server variable, this requires adding an "Allowed Server Variables": this is done by the following steps:

View Post»


Utilize gzip compression in IIS

Written by Wayne Ye  Friday, December 10, 2010

GZIP format is developed by GNU Project and standardized by IETF in RFC 1952, which MUST be considered by web developers to improve their websites' performance, there are several Quintessential articles documented using gzip compression, they are:

10 Tips for Writing High-Performance Web Applications
Best Practices for Speeding Up Your Web Site
How To Optimize Your Site With GZIP Compression
IIS 7 Compression. Good? Bad? How much?

A gzip compressed HTTP package can significantly save bandwidth thus speed up browser rendering after use hitting enter, so that user experience got improved finally, nowadays most of the popular browsers such as IE, Firefox, Chrome, Opera support gzip encoded content (please refer: http://en.wikipedia.org/wiki/HTTP_compression).

PS: the other compression encoding is deflate, "but it's less effective and less popular" (refer: http://developer.yahoo.com/performance/rules.html). Yahoo uses gzip compression and suggest developers do that:


Compression in IIS

For ASP.NET developer who host website

View Post»