当只有页面由f5重新加载时,django url cache才有效

时间:2018-04-21 05:08:25

标签: javascript jquery django

可能是this page的副本。

我的urls.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'),
]

my_template.html:

<div class="non_seen" id="url_custom" data-custom="{% url 'alphabet:alp' alp='a' %}"></div>

我的模板文件(来自my_template.html)有一些js(jquery)代码可用于该网址:

$('#btn_custom').click(function (e) {
    e.preventDefault();
    location.href = $('#url_custom').attr('data-custom');
}

当我监控我的redis-cli时,如果我重新加载(刷新,点击F5)页面cache get or set event,那么我的redis监控日志会127.0.0.1:8000/a,但当我点击#btn_custom时,会出现&#btn_custom #39;没有这样的事件。

问题:为什么会发生这种情况以及如何对每个请求进行缓存(包括点击package com.grayraven.garage; import android.content.Context; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import org.eclipse.paho.android.service.MqttAndroidClient; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; public class MainActivity extends AppCompatActivity { final String TAG = "Garage_Main"; private static Context mContext = GarageApp.getAppContext(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this.getApplicationContext(); setContentView(R.layout.activity_main); } final String broker = "10.211.1.127:1883"; final String password = "monkey123"; final String subscriptionTopic = "garage_door"; MqttConnectOptions options = new MqttConnectOptions(); options.setUserName("pi"); //cannot resolve setUserName!!! options.setPassword(password.toCharArray()); //cannot resolve setPassword!!!! String clientId = MqttClient.generateClientId(); MqttAndroidClient client = new MqttAndroidClient(mContext, broker, clientId); /// rest of code works so omitted for clarity 时不仅点击F5?

0 个答案:

没有答案