django css file cached

django cache busting
django static files production
manifest file django
django clear css cache
django static files not working
no module named 'django/contrib staticfiles templatetags
django static files not found
django loading old css

I'm having a css file and i want to modify it to fit my needs. The problem is that it seems to be cached somewhere, as i just cannot see the changes, no matter what i do in the css file. I am sure i am pointing to the right file, as by now i'v modified in it, and it worked. Is there any setting so that i can turn the cache off? Thanks!

Just go into your site, view source, and copy the link to your CSS file. Verify the link, verify it's being modified. Refresh the CSS file manually via your browser to get the latest.

This isn't a Django issue.

Cache busting in Django, Cache busting CSS with query strings. Because visitors' browsers locally store a cached copy of the static files, there is a possibility for them not  Managing static files (e.g. images, JavaScript, CSS)¶ Websites generally need to serve additional files such as images, JavaScript, or CSS. In Django, we refer to these files as “static files”. Django provides django.contrib.staticfiles to help you manage them. This page describes how you can serve these static files.

As pointed out in this article, you could force django reload your css file by using a parameter in your css link :

<link rel="stylesheet" type="text/css" href="/site_media/css/style.css?{% now "U" %}" />

This is a timestamp which takes a different value every second, so you could even reload your css second every second if needed!

Dynamically Cache Static Files using Django and Nginx, Dynamically Cache Static Files using Django and Nginx because it is using an out-of-date cached version of the JS or CSS files I updated. Django can store its cached data in your database. This works best if you’ve got a fast, well-indexed database server. To use a database table as your cache backend: Set BACKEND to django.core.cache.backends.db.DatabaseCache; Set LOCATION to tablename, the name of the database table. This name can be whatever you want, as long as it’s a valid table name that’s not already being used in your database.

Did you try appending a datetime stamp to the end of the request? I know some frameworks do this to .js and .css files automatically to prevent caching.

The staticfiles app | Django documentation, Setting up static file caching. Even a fairly light-weight page will probably load some CSS and JS, and a few images - it's pretty easy to find each page load  I can't reproduce this on current trunk using STATICFILES_STORAGE = '' (which uses the CachedFilesMixin). I even tried converting the css file to latin1, which garbled the contents, but still worked using collectstatic.

Instead of using complicated solutions you can add extra parameter to your includes in the templates.

For static includes:

<script src="{% static 'js/polls/polls.js' %}?version=1"></script>

For direct includes:

<link rel="stylesheet" type="text/css" href="/site_media/css/style.css?version=1" />  

Note the ?version=1 in the code. Every time you're modifying the file, change this version in the template, so browser will be forced to reload the file.

Of course you can use even now as suggested by @rom, but if your static files are not being changed very often, it's not the smartest idea to don't use cache at all.

Setting up static file caching, Not entirely sure, but I can guess that: CSS_HASHING_METHOD = 'mtime/​content/none' is the only way to set the suffix for our output file. Django will automatically find any folders called "static" inside any of your apps' folders. Then it will be able to use their contents as static files. Your first CSS file! Let's create a CSS file now, to add your own style to your web page. Create a new directory called css inside your static directory.

Request: version number caching css/js · Issue #783 · django , Compresses linked and inline JavaScript or CSS into a single cached file. Why another static file combiner for Django?¶. Short version: None of them did exactly​  django.contrib.staticfiles collects static files from each of your applications (and any other places you specify) into a single location that can easily be served in production. For an introduction to the static files app and some usage examples, see Managing static files (e.g. images, JavaScript, CSS). For guidelines on deploying static files

Django Compressor, The reason is because many web browsers cache the stylesheet for faster future reloading. Obviously you don't want to have to get your users to  Django Compressor processes, combines and minifies linked and inline Javascript or CSS in a Django template into cacheable static files. It supports compilers such as coffeescript, LESS and SASS and is extensible by custom processing steps. Django Compressor is compatible with Django 1.11 and newer.

CSS auto reload with Django templates, Say the browser has the CSS file cached for one year (not uncommon). <link rel="stylesheet" href="global.css?v=<?php echo $cssVersion; ?>"> Django can also use a far future Expire headers by configuring ManifestStaticFileStorage. When the user accesses the URL, it will take the cached .js and .css files. That is the reason those new changes will not appear to the user. The user either has to clear the browser cookie & reload the page or else he or she has to do a hard refresh of the page by pressing Ctrl+F5.

  • Which browser are you using? Blow out your cache.
  • More common way is to use something like .../style.css?version=1 and increment the version every time you make a change
  • it is not a .css added as a MEDIA parameter to a view.