Archive for the 'web' Category

mod_rewrite for IIS

Apparently IIS7 is gonna have a url rewrite filter that will be compatible with Apache’s mod_rewrite. About time.
If you can’t wait or can’t upgrade then there are other options. I needed one for a site and found a nice free one called IIRF. It’s distributed under the Microsoft Permissive License.

If you don’t have any idea of what a url rewriter does – well it’s server side software that allows the browser to request http://foo/bar/bam and receive http://foo/something/dispatch.cgi?q=bam.
This is useful for easy to remember urls and also for search engine optimisation. Go google mod_rewrite for more details.



Mystery of the missing images

Just spent longer than I would have liked finding out why some images on my site weren’t displaying under Firefox 3 but were fine under IE7.
According to Firebug the images were being downloaded, but they were not being rendered. So, I looked at the rendered DOM source and could see that style=”display: none;” had been added to the img tag.
I was pretty sure that none of my scripts were doing anything like that, and after searching them all and checking the CSS for quite some time I eventually tracked the problem down.
And guess what!? It wasn’t a problem at all, it was the excellent FF plugin called AdBlockPlus just doing it’s job. The image path had the string ‘advert’ in it and had therefore had the offending style tag added. It was a very simple matter to disable AdBlockPlus for my site and that was problem solved!



Speeding up page impressions

I had cause to review a web servers performance recently after it was noted that one site was being served extremely quickly to the client and the other seemed woefully slow.

Well the webserver in this case was IIS 5 but the ideas discussed are relevant to other webservers such as Apache.

Firstly utilising a couple of excellent plugins for the FireFox 3 browser, namely Firebug and YSlow for Firebug, I was able to instantly see performance stats about how a server is serving a page to the client.

It was clear that the site I was reviewing wasn’t using any settings for caching and also wasn’t using gzip compression for on the fly compression of the HTTP response.

These sorts of thing can generally be set in a number of ways – either in server side script or configured for a given resource.

So, to summarise the changes I made in IIS for this site, I made sure all images were being stored in a folder called images from the root of the site. Then from IIS snapin right click the folder and choose properties, choose the HTTP Headers tab and enable content expiration for images.

Next I enable gzip compression by right clicking the computer icon in IIS and clicking properties, then choosing Edit under Master Properties and clicking on the Service tab – yeah pretty well hidden away really.

Under IIS if you choose to “compress application files” only the following will be compressed “asp”, “dll”, “exe”, I know this is true of IIS 6 as well as IIS 5 – search google for “Customizing the File Types IIS Compresses” to see how to get round that – you’ll likely want to add aspx and php if your server is supporting them.

Here’s the contents of a batch file that can be run on the server to set this up, just make sure that adsutil.vbs is available where the script is looking.

IISreset.exe /stop
cd c:\Inetpub\AdminScripts
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart



html tables, columns and javascript

While writing a little javascript today I needed to dynamically add or remove columns from a table based on user input. Well I see there is a insertRow to add a new row, fair enough, but no equivalent function appeared available to add a column.

Anyway I found a solution quick enough at http://www.mredkj.com/tutorials/tableaddcolumn.html

It basically involves iterating the rows in the table (or table section), and calling insertCell for each row.

Thanks to Keith Jenci for the tutorial.




You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.