Make Your Websites Work Faster or How I Tune .htaccess for IIS
In April 2010 Google publicizeed, that speed of a web site will be considered as an aspect of web search ranking. This means that web site begetter and webmasters needfulness to optimize their websites. What is the best way to do that? What if web developers are out of reach? What if making over the code is not an option? We have offer several undecorated and nippy solutions for improving your web site performance using Helicon Ape. To inaugurate with you need to download Helicon Ape and install it on your Windows server. Autochthon Helicon Ape Manager allows you to var your web server setting using .htaccess for IIS text files. General unvarnished advices:
1. Cache statics
Caching static content (pictures, css files, javascript files) on the client’s side (in browser) means that having received static file once browser saves it in cache and doesn’t produce a request to the server next time the html-document is requested. File will be taken from cache. Both sides win: client sends less calls, web site is working faster and server courses less requests. For sample, ordinary WordPress post page has over a dozen links to the static files (css files, pictures, scripts). Time pass on downloading these files surpasses time spent on downloading the post itself. Once Formerly having caching empowered the static content will be downloaded only once. While moving to the succeeding page the only thing that will be downloaded is page itself. All static files will be taken from cache. In order to make browser cache static content, http-response must contain specific headers: Expires and Cache-Control. Those headers are set by mod_expires and mod_headers modules. For enabling caching, create using .htaccess for IIS file with the following content within the static folder:
ExpiresActive On
Header set Cache-Control public
ExpiresByType image/.+ “access 15 days”
ExpiresByType text/css “access 5 days”
ExpiresByType application/x-javascript “access 5 days”
ExpiresByType application/javascript “access 5 days”
In case there’s no such directory for static content and files are spread across folders of web site, than if you create following .htacces in the root of the site it will cache all static content on the web site by file extension:
<Files ~ \.(gif|png|jpg|css|js)>
ExpiresActive On
Header set Cache-Control public
ExpiresByType image/.+ “access 15 days”
ExpiresByType text/css “access 5 days”
ExpiresByType application/x-javascript “access 5 days”
ExpiresByType application/javascript “access 5 days”
</Files>
This configuration makes server send http-responses to clients with information that pictures are to be cached for 15 days and scripts and css-files for 5 days.
2. Compress responses on the run
In procedure to save some moment on loading the content, you can condense it. All designer browsers are open to receive comressed gzip-traffic. Text files (html-files, css-files, scripts, json-data) can be easily compressed and allow you to save 20-90% of traffic. Same time, music and video files can hardly be compressed as they have already be sized with special codecs. Here’s an example of enabling gzip-compression. Add the following line in .htaccess in the root of web site:
SetEnvIf (mime text/.*) or (mime application/x-javascript) gzip=9
As you can see, this configuration is quite simple. It’s enough to have all text documents (html, css files) and javascript-files compressed before going to the client’s side. It is worth saying, that server compresses responses only for those browsers, that support compressing. Browser informs server about its features through the headers of html-request.
3. Cache dynamic responses at server side
Repeatedly great quantum of requests, addressed to database server, prevent the web site fulfillment. For example, blog’s major page shows just entries, recent comments, navigation menu, category list and tags. Those are several complicated requests to database. In case that information does not change often or the appropriateness is not significant, html-responses need to be cached without hesitation. You can select to cache the blog’s main page once in 5-10 minutes. But that would be enough to meliorate main page performance in browser. Almost, application developer has determine what pages need to be cached and for how long. Also he has to bring into life caching mechanism “out of the box” . Unfortunatelly, that doesn’t occur most of the time. Likely, mod_cache in Helicon Ape will simply and easily permit you to empower caching at server side. mod_cache assistances two types of cache: disk cache and memory cache. First type saves caches data on the drive, and the second one does on memory. Memory caching is more preferable. If your server doesn’t have enough RAM, use disk cache. For example, to cache site’s homepage, we need to add the following lines in .htaccess in the root:
Header set Cache-Control public,max-age=600
SetEnvIf request_uri ^/$ cache-enable=mem
This configuration enforces caching of site’s homepage request for 10 min (600sec). Response are cached in memory. Be careful! You need to enable caching carefully. For example, pages that need authentificaton mustn’t be cached as they comprise private data and need to provide uncommon information for uncommon users. In any cases, caching must be taking application logic into account. We’ve reviewed three simple steps for increasing the speed of your web site. Besides tangible speed-boost, which you will notice at once, the acceleration must well enhance your rating in search engine results. You can see fulfillment graph of www.helicontech.com made using Google Webmaster tools after a simple optimization. So furnish your site with these tricks and possess dual benefit!