PHP Advanced and Object-Oriented Programming
Larry Ullman
 
Last-Modified 最后修改时间
Expires 过期时间
Pragma 编译提示
Cache-Control 缓存控制
如缓存系统发现Last-Modified的值比页面缓存版本的时间更接近当前时间,它就知道应该使用来自服务器的更新页面版本。
 

Caching—both in Web browsers and proxy servers—can be affected using PHP’s header() function. Four header types are involved:

• Last-Modified

• Expires

• Pragma

• Cache-Control

The first three header types are part of the HTTP 1.0 standard. The Last-Modified header uses a UTC(Coordinated Universal Time) date-time value. If a caching system sees that the Last-Modified valueis more recent than the date on the cached version of the page, it knows to use the new version from the server. Expires is used as an indicator as to when a cached version of the page should no longer be used (inGreenwich Mean Time).

Setting an Expires value in the past should always force the page from theserver to be used:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

Pragma is just a declaration for how the page data should be handled. To avoid caching of a page, use

header("Pragma: no-cache")

The Cache-Control header was added in HTTP 1.1 and is a more finely tuned option.

Directive         Meaning

public        Can be cached anywhere

private           Only cached by browsers

no-cache          Cannot be cached anywhere

must-revalidate  Caches must check for newer versions

proxy-revalidate  Proxy caches must check for newer versions

max-age      A duration, in seconds, that the content is cacheable

s-maxage     Overrides the max-age value for shared caches

Keep all systems from caching a page

header("Last-Modified: Mon, 26 Jul 2016 05:00:00 GMT"); //Right now!

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //Way back then!

header("Pragma: no-cache");

header("Cache-Control: no-cache");

Pragma: no-cache的更多相关文章

  1. META元素使用的简单学习

    meta标签是我们学习html时容易忽略的标签,其实它的作用很大,下面就一些网上关于meta标签的讲解内容做一个简单的归纳. META标签共有两个属性,它们分别是Http-equiv属性和Name属性 ...

  2. snoopy 强大的PHP采集类使用实例代码

    下载地址: http://www.jb51.net/codes/33397.html Snoopy的一些特点: 1抓取网页的内容 fetch 2 抓取网页的文本内容 (去除HTML标签) fetcht ...

  3. PHP抓取采集类snoopy介绍

    PHP抓取采集类snoopy介绍 一个PHP的抓取方案 在 2011年07月04日 那天写的     已经有 10270 次阅读了 感谢 参考或原文   服务器君一共花费了14.288 ms进行了2次 ...

  4. snoopy(强大的PHP采集类) 详细介绍

    Snoopy是一个php类,用来模拟浏览器的功能,可以获取网页内容,发送表单,可以用来开发一些采集程序和小偷程序,本文章详细介绍snoopy的使用教程. Snoopy的一些特点: 抓取网页的内容 fe ...

  5. iOS 断点上传文件

    项目开发中,有时候我们需要将本地的文件上传到服务器,简单的几张图片还好,但是针对iPhone里面的视频文件进行上传,为了用户体验,我们有必要实现断点上传.其实也不是真的断点,这里我们只是模仿断点机制. ...

  6. 记录一个nginx的配置

    rt #user xiaoju; worker_processes ; #error_log logs/error.log notice; #error_log logs/error.log debu ...

  7. SDWebImage源码解析

    但凡经过几年移动开发经验的人去大公司面试,都会有公司问到,使用过哪些第三方,看过他们的源码嘛?而SDWebImage就是经常被面试官和应聘者的提到的.下面将讲述SDWebImage的源码解析以及实现原 ...

  8. SDWebImage之SDImageCache

    SDImageCache和SDWebImageDownloader是SDWebImage库的最重要的两个部件,它们一起为SDWebImageManager提供服务,来完成图片的加载.SDImageCa ...

  9. python scrapy 登录知乎过程

    前面了解了scrapy框架的大概各个组件的作用, 现在要爬取知乎数据,那么第一步就是要登录! 看下知乎的登录页面发现登录主要是两大接口 一: 登录页面地址,获取登录需要的验证码,如下图 打开知乎登录页 ...

  10. iOS通过切片仿断点机制上传文件

    项目开发中,有时候我们需要将本地的文件上传到服务器,简单的几张图片还好,但是针对iPhone里面的视频文件进行上传,为了用户体验,我们有必要实现断点上传.其实也不是真的断点,这里我们只是模仿断点机制. ...

随机推荐

  1. Python之虚拟环境管理

    Python本身有很多个版本,第三方的Python包又有很多可用的版本,所以经常会遇到下面的问题: 运行不同的Python程序,需要使用不同版本的Python(2.x或3.x). 在同一中Python ...

  2. 【代码审计】iZhanCMS_v2.1 代码执行漏洞分析

      0x00 环境准备 iZhanCMS官网:http://www.izhancms.com 网站源码版本:爱站CMS(zend6.0) V2.1 程序源码下载:http://www.izhancms ...

  3. Linux下chkconfig命令详解转载

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法:chkconfig [--ad ...

  4. 【Linux】将终端的命令输出保存为txt文本文件

    Linux中的终端很方便,可以直接复制粘贴的. 之后开一个gedit文本编辑器,把复制到的内容粘贴就可以的. 不像windows的cmd控制台,需要先右键标题栏,选择编辑->全选/标记,在右键标 ...

  5. Linux IPC BSD socket编程基础

    头文件 #include<unistd.h> #include <sys/types.h> #include <sys/socket.h> #include< ...

  6. php原生实现图片上传和查看

    先上源码:upload_file.php <html> <body> <form action="upload_file.php" method=&q ...

  7. PHP中常见问题总结

    [1]页面之间无法传递变量 get,post,session在最新的php版本中自动全局变量是关闭的,所以要从上一页面取得提交过来得变量要使用$_GET['foo'],$_POST['foo'],$_ ...

  8. 【git】 linux 环境安装git

    1 安装git依赖包 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUti ...

  9. 【Mac】WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

    使用Mac 自带终端 链接服务器时候,报错如下 处理办法: 第一种:  直接删除:  /users/username/.ssh/known_hosts  文件 第二种: ssh-keygen -R   ...

  10. Excel 公式集

    1.  Excel 公式集 按身份证计算年龄 按日计算的 (2018/12/20)(身份证 C2): =TRUNC((DAYS360(CONCATENATE(MID(C2,7,4),"/&q ...