鍍金池/ 問答/Java  PHP  Python  C  HTML/ ajax, cache: true,get請求,但是好像并沒有從緩存中讀取數(shù)據(jù),

ajax, cache: true,get請求,但是好像并沒有從緩存中讀取數(shù)據(jù),如下圖和代碼

問題

當我刷新的時候,又重新請求數(shù)據(jù)了,(數(shù)據(jù)源應該還沒有變)
clipboard.png

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>
        $.ajax({
            url: 'https://cnodejs.org/api/v1/topics',
            type: 'GET',
            cache: true,
            success: function(response) {
                console.log(response)
            },
            error: function(error) {
                console.log(error)
            }
        })
    </script>
</body>

</html>
回答
編輯回答
還吻

是不是服務器返回的header里設置了不允許緩存呢

2018年6月11日 03:26
編輯回答
薄荷綠

服務器返回的Header頭中未設置緩存,看看topics請求的ResponseHeaders,是否有允許的緩存字段。

2018年1月1日 20:16