Answer the question
In order to leave comments, you need to log in
How can I disable the strange /static/ cache protection behavior in Django?
Weird calls to JavaScript files from the /static/ folder in Django have been noticed. Basically, the files are called correctly. For example:
"GET /static/js/jquery-2.1.1.min.js HTTP/1.1" 304 0
"GET /static/js/login-logout.js?_=1428801732678 HTTP/1.1" 200 1377
{% load staticfiles %}
<script src="{% static 'js/jquery-2.1.1.min.js' %}" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#login-logout').load('login-logout');
})
</script>
{% load staticfiles %}
<script src="{{ STATIC_URL }}js/login-logout.js" type="text/javascript"></script>
<script src="/static/js/loginlogout.js" type="text/javascript"></script>
then all the same, this ?_=12bunch4digits5 is added to the call
Answer the question
In order to leave comments, you need to log in
Django doesn't do magic
To clarify, look at the code of the page that you got - it's probably not there _=12345
So django has nothing to do with it
And what does jq ajax with its anti-
cache
https://api.jquery.com/load/
cache jq globally however not worth it
But for templates that do not inherit from the base one, for exampledon't save on matches - make one js file and load it on the first run. If the file is less than 256kb, no one will notice it (unless you have a specific site)
$(document).ready(function(){
// $('#login-logout').load('login-logout');
$.ajax(function(){
cache: true,
url: 'login-logout.html',
dataType: 'html'
success: function(html){
$('#login-logout').html(html) }
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question