HUDL.NET

How to bypass Byethost CSS caching?

So you updated your css file, clicked reload and the changes didn't appear until a few minutes later? Because the basic hosting at Byethost is free they are saving some bandwidth by caching your stylesheet. It's harmless unless you are using their otherwise excellent service for development.
Well... good news. There is a rather simple workaround. You just have to trick the server into 'thinking' that you renamed your .css file and thus making it recache it.

First you edit your .htaccess file with:

RewriteEngine on
RewriteBase /
RewriteRule ^style.*$ style.css



This will redirect any request beginning with 'style' to your style.css.

Then insert this line in the <head> section of your page:

<link rel="stylesheet" type="text/css" href="/path/to/your/style<?php print(rand(1,1000));?>.css"/>



This will insert a random number between 'style' and '.css' and so tricking the server wih a 'new' filename :D Because of the .htaccess thingy this will point to style.css. Update at will!

NOTE: 'style' is an example name but it MUST be the same in all cases above. Replace it (and the path) with the name of your stylesheet file. Of course the name of the file must be 'pagename'.php not .html or anything else.

Have fun!