How do I prevent people from 'leeching' my CSS or JS files?
I've heard a few people complain that external sites have linked to their CSS or JS files, which is both a waste of bandwidth and a potential copyright violation. Unfortunately, there is no straightforward way to prevent this from happening, and have fun trying to pursue it legally -- I was an expert witness in an Internet-related trial a few years ago, and it's amazing how much crap a lawyer can get away with it simply because the judge has no technical savvy whatsoever.
In any case, there are ways to prevent people from borrowing these file types, and it's very similar to the method described in Article #2276, used to protect images from being swiped.
The basic concept is that you serve up the CSS or JS from ASP, and the ASP page checks the referer to make sure it's on the same domain. So, for example, you can do this:
Where js.asp may have the following code:
And css.asp might look like this:
As with the images solution, note that this will be a bigger performance hit... and may affect how JS / CSS files are cached.
Related ArticlesCan I include a file in both server-side and client-side script?
Can I read / write a user's file without a prompt?
Can I rename a file using FileSystemObject?
Could I get some help working with files using FileSystemObject?
How do I avoid 'the red x' when an image is missing?
How do I change the modified time of a file?
How do I create / manipulate images from ASP?
How do I dynamically include files?
How do I find the owner, author, and other properties of a file?
How do I get a list of a folder's subfolders?
How do I get the name of the current URL / page?
How do I prevent people from 'leeching' my images?
How do I retrieve a random file from a given folder?
How do I send the correct filename with BinaryWrite?
How do I sort a list of files?
How do I use FileSystemObject to create a file on the client?
Why do I get 'Disk not ready' errors with FileSystemObject?
Why do I get 'Invalid procedure call or argument'?
Why do I get 'Path not found' errors with Scripting.FileSystemObject?
Why do I get 'Permission Denied' errors with FileSystemObject?
Why do I get 800A0034 errors?
Why do I get 800A003E / Input past end of file errors?
Why do I get 800A0BBA errors?
Why do I get 800A0BBC errors?
Why do I get an 'Invalid Path Character' error?
Why do I get permissions errors after upgrading to Windows XP?
Why does FileSystemObject hang all of a sudden?
Why is 'the operation completed successfully' an error message?