zoukankan      html  css  js  c++  java
  • fetch缓存问题

    本地浏览器测试没有问题,但是在移动设备上出现了调用方法值一直会进行缓存的问题。

    由于代码使用了闭包,原以为是这个原因造成的,声明了新的变量并不起作用,百度了半天才发现fetch这个东西有一个缓存设置cache: "force-cache",按照说明修改为no-cache,问题搞定!!!

    if (window.fetch && method == 'fetch') {
            let requestConfig = {
                credentials: 'include',
                method: type,
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    'Authorization':"Bearer " + localStorage.getItem("access_token2"),//gougou 2021-5-12
                },
                mode: "cors",
                //cache: "force-cache"//会有缓存
                cache:"no-cache"
            }
    
            if (type == 'POST' || type == 'DELETE') {
                Object.defineProperty(requestConfig, 'body', {
                    value: JSON.stringify(data)
                })
            }
  • 相关阅读:
    MongoDB高级操作
    MongoDB基本操作
    Python字符串
    Git标签和别名管理
    Git分支管理
    Git远程仓库(github
    Git分布式版本管理工具基本使用方法
    CentOS7防火墙
    CentOS7新特性
    Linux系统初始流程
  • 原文地址:https://www.cnblogs.com/gougou1981/p/14840747.html
Copyright © 2011-2022 走看看