httpd: disabling keep alive for hot linked images
Published January 25th, 2010
Lets say you are running a website, and you don’t mind people hot linking images, like your Logo, or other resources, and at the same time, you want to enable a (short) Keep Alive timeout for your normal users.
Normal anti-hot linking recipes, like the one on the HTTPD Wiki are all about disabling access to the image completely.
If you have lots of people hot linking, these users can use up valuable Keep Alive sessions, so the easiest way to solve this problem is to disable Keep Alive for just those clients viewing a hot linked image.
This is possible by using mod_setenvif and the nokeepalive environment variable:
SetEnvIfNoCase Referer (.+) nokeepalive
SetEnvIfNoCase Referer (.)example.com(.) !nokeepalive
What this does is first disable KeepAlive for all users that have a Referer set, and then re-enable keepalive for those users who are coming from ‘exmaple.com’, which should be replaced with your site.
Written by Paul Querna, CTO @ ScaleFT. @pquerna