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. lua 对表的简单序列化与反序列化

    参考文档:http://blog.csdn.net/xiaodan007/article/details/7096718 function sz_T2S(_t) local szRet = " ...

  2. 关于C中函数传参的一点理解

    一般来说c传值分为传值与传指针,Java里没有指针,因此只有传值,但是Java里传值分为简单变量传值和引用型变量传值,从本质上来说这两者没啥区别. 下面主要说的是传参时对原变量的影响: 最初练习创建单 ...

  3. U3D之Editor扩展学习

    Unity3D提供了强大的编辑器扩展机制,在项目开发中,如果可以将一些繁琐的工作放在编辑器扩展中进行,则会大大提高效率.本文对编辑器扩展进行了一些总结,希望对有兴趣编写编辑器扩展的开发人员有所帮助.当 ...

  4. URI跳转方式地图导航的代码实践

    本文转载至 http://adad184.com/2015/08/11/practice-in-mapview-navigation-with-URI/ 前言 之前介绍了我正在做的是一款定位主打的应用 ...

  5. DELPHI XE Android 开发笔记

    第一次编译时,设定android SDK: F:\RAD Studio XE6\PlatformSDKs\adt-bundle-windows-x86-20131030\sdk F:\RAD Stud ...

  6. Esper学习之十五:Pattern(二)

    上一篇开始了新一轮语法——Pattern的讲解,一开始为大家普及了几个基础知识,其中有说到操作符.当时只是把它们都列举出来了,所以今天这篇就是专门详解这些操作符的,但是由于篇幅限制,本篇先会讲几个,剩 ...

  7. C# 中对COOKIES的操作

    HttpUtility.UrlDecode HttpUtility.UrlEncode HttpContext.Current.Request.Cookies["UserCode" ...

  8. Android JSON语法解析示例

    参考: http://www.open-open.com/lib/view/open1326376799874.html https://www.cnblogs.com/jycboy/p/json_x ...

  9. Sencha Touch 实战开发培训 电子书 基础篇

    本期课程基于Sencha Touch 2.4.1,属于新手实战入门课程,侧重于实用性. 课程目录: 开源Demo:https://bitbucket.org/moLangZaiShi/demo 本课程 ...

  10. CF 434C Tachibana Kanade's Tofu[数位dp+AC自动机]

    Solution //本代码压掉后两维 #include<cstdio> #define max(a,b) (a<b?b:a) using namespace std; inline ...