zoukankan      html  css  js  c++  java
  • url加时间戳避免再次请求当前路径出现的缓存问题

    转自 https://blog.csdn.net/qq_36769100/article/details/54564784

    问题:在IE8下用validate的异步验证时,有时验证不起作用,也不走后台。

    1.先解释一下,为什么要加时间戳:

    URL后面添加随机数通常用于防止客户端(浏览器)缓存页面。 浏览器缓存是基于url进行缓存的,如果页面允许缓存,则在一定时间内(缓存时效时间前)再次访问相同的URL,
    浏览器就不会再次发送请求到服务器端,而是直接从缓存中获取指定资源。

    2.加时间戳的方法:

    rules: {
    no: {remote: "${ctx}/sys/user/checkNo?oldNo=" + encodeURIComponent('${user.no}')+"&t="+new Date().getTime()},
    macAddress: {remote: "${ctx}/sys/user/checkMac?oldMacAddress=" + encodeURIComponent('${user.macAddress}')+"&t="+new Date().getTime()},
    mobile : { isMobile:true }
    },

    在URL中加时间戳就会保证每一次发起的请求都是一个不同于之前的请求,这样就能避免浏览器对URL的缓存。

  • 相关阅读:
    单例模式
    js事件
    oracle_to_excel
    jquery_2
    jquery_1
    4.linux 复制,删除,重命名
    一个tomcat下部署多个springboot项目
    3.centos7 安装oracle
    桥接模式
    组合模式
  • 原文地址:https://www.cnblogs.com/person008/p/9487353.html
Copyright © 2011-2022 走看看