Home : Internet : Server : Apache : Mod Rewrite : Server Load Issues

Server Load Issues

You do not need to be a software engineer to realise the more work a computer has to do, the longer it will take. In most cases, the effect of using mod_rewrite on your server load will be insignificant.

All the same, you should be sensible in determining where and when to make use of it. As I said in the introduction: Remember, your server will need to consider your rewrites every time a request is made - that is for every image, every file and every page loaded, every time.

If you have one file you wish to send a 301 moved header from, create that file and use a script to send the header. For obvious reasons, using mod_rewrite in that circumstance would not be optimal.

On high traffic servers, load becomes more of an issue. To reduce the impact mod_rewrite has, there are two things you can do.

Firstly, if possible place your rewrite codes in the httpd.conf - most control panels allow you to edit your VirtualHost section for each domain, simply add them in there. You may need to update the paths if your rules use them. The downside to this is you will need to restart your server.

This should be preferred over using a .htaccess file as the httpd.conf is compiled when Apache starts, whereas an .htaccess file must be interpreted at every request.

Secondly, if you must use a .htaccess file, place it as deep as possible. By that I mean, if you are using mod_rewrite to stop hotlinking in a directory such as /html/images/site/protected/, place the .htaccess file in the protected directory, not the root of your domain. That way it only needs to be interpreted when a request is made to that directory, as opposed to being interpreted for every request for every file.

Subscribe to us on YouTube