Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript django url缓存仅在f5重新加载页面时工作_Javascript_Jquery_Django - Fatal编程技术网

Javascript django url缓存仅在f5重新加载页面时工作

Javascript django url缓存仅在f5重新加载页面时工作,javascript,jquery,django,Javascript,Jquery,Django,也许是复制品 我的URL.py: from django.views.decorators.cache import cache_page app_name = 'alphabet' urlpatterns = [ re_path(r'^(?P<alp>a|b|c|d|e)/$', cache_page(60 * 15)(views.alp), name='alp'), ] <div class="non_seen" id="url_custom" data-cu

也许是复制品

我的URL.py:

from django.views.decorators.cache import cache_page

app_name = 'alphabet'

urlpatterns = [
    re_path(r'^(?P<alp>a|b|c|d|e)/$', cache_page(60 * 15)(views.alp), name='alp'),
]
<div class="non_seen" id="url_custom" data-custom="{% url 'alphabet:alp' alp='a' %}"></div>
$('#btn_custom').click(function (e) {
    e.preventDefault();
    location.href = $('#url_custom').attr('data-custom');
}
当我监视我的redis cli时,如果我重新加载(刷新,单击F5)页面
127.0.0.1:8000/a
,就会出现redis监视器日志
cache get或set event
,但当我单击
#btn_custom
时,就不会出现类似的事件


问题:为什么会发生这种情况,以及如何将其缓存到每个请求中(包括单击
#btn_custom
,不仅仅是在单击F5时?

我不知道您的问题在哪里,但是您发布的代码根本不起作用-
{%url'字母表:alp'}
应该会引发一个
NoReverseMatch
错误,因为您没有提供正则表达式中使用的
alp
参数。@solarissmoke谢谢,我编辑过。为当前页面的相同URL设置
location.href
不会导致浏览器重新加载页面-因此Django根本看不到请求。