Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS not updating on local python httpserver restart

I'm fairly new to the world of web dev and http servers and the like, but I have a basic shell script as follows:

PORT=2600 
if [[ $1 =~ ^[0-9]+$ ]]
  then PORT=$1
fi

echo "Starting local http server (ctrl-c to exit)"
echo ""
echo "  Demo:   http://127.0.0.1:$PORT/demo"
echo ""
python -m SimpleHTTPServer $PORT

It seems to work alright for just putting things up, but when I update the css file in my demo, it rarely and inconsistently will update the css displayed on the page. The changes to any html it renders fine, and it has occasionally shown the css changes, but I feel like I'm doing something fundamentally wrong here. Thoughts?

like image 905
Slater Victoroff Avatar asked Feb 23 '13 18:02

Slater Victoroff


1 Answers

The issue is browser caching. You can a) clear browser cache or turn on incognito browsing or b) append some sort of cache busting to your css/js resources ie foo.css?(timestamp) or foo.css?(version#) etc. For larger systems, the latter is better so that you don't force users to clear browser cache after a code push to production.

like image 119
Brad Avatar answered Sep 22 '22 17:09

Brad