0

I'm working on several Django projects on my local machine, following a single page application architecture. To initiate the server, I have a couple copies of a script in my /bin folder containing

#!/bin/bash

python /path/to/app/manage.py runserver 8080

and have each script with the app name. This makes the application accessible via localhost:8080. In addition, I usually have the majority of my site CSS inside main.css

My issue is that I seem to be coming across a caching issue with Firefox, regardless of which application server is running. Sometimes a page will load with almost no CSS styling, but the jQuery UI elements will be initialized and I can interact somewhat with the application, although the functionality and styling is seriously broken. Refreshing the page shows no improvement, and no errors are shown in the console.

Clearing the cache and changing the port in the scrip seem to solve the issue, but it requires me to have bookmarks for each project, whereas it is pretty convenient to have a single localhost:8080 URL for all projects.

Has anyone come across this issue, and is there a solution other than clearing cache and changing ports?

Jason
  • 11,263
  • 21
  • 87
  • 181

2 Answers2

1

This thread discusses methods to prevent client side caching of content served by the development server in Django:

Fighting client-side caching in Django

I prefer to simply disable caching in my browser though, seeing that I spend so much time on developing that I don't want to bother with the hassle of trying to prevent it in my own code.

A simple web search for "how to disable caching in firefox" came up with this:

http://support.mozilla.org/en-US/questions/764993

I'm pretty sure that searching for the same thing for different browsers will also give you expected results.

EDIT:

These guys also seem to go pretty in depth about how to prevent the caching of static files when using the Django development server.

Turn off caching of static files in Django development server

Community
  • 1
  • 1
0

Just add something like this to /etc/hosts:

127.0.0.1    site1.dev
127.0.0.1    site2.dev

Visit site1.dev:8080, now site1 has its own cache and cookies (session) in the browser.

JimmyYe
  • 844
  • 6
  • 6