2π
β
As @yedpodtrzitko pointed out, adjusting the cache headers of the web page in Django is pointless.
This part looks wrong:
$.get('{{ MEDIA_URL }}{{ data_to_modify.thumbnail.name }}?cachebuster='+Math.floor(Math.random()*100 +1), function(data) {
{{ MEDIA_URL }}{{ data_to_modify.thumbnail.name }}
is the url of of the image you want to display right? (you use the same url in the html img
tag)
In that case it doesnβt make sense to load that url via ajax.
It seems like you donβt need ajax at all, you just need to periodically update the src
attribute of the img
tag, with the cachebuster querystring appended:
<script type='text/javascript'>
$(document).ready(function() {
var $img = $('#imageactual');
setInterval(function() {
$img.attr('src', '{{ MEDIA_URL }}{{ data_to_modify.thumbnail.name }}?cachebuster='+Math.floor(Math.random()*100 +1));
}, 2000);
});
</script>
π€Anentropic
Source:stackexchange.com