dounei9043 2012-05-03 10:59
浏览 137
已采纳

如何检查页面是否使用php缓存

...and whether it was cached 30 days ago,,

I am using this code:

 $page=get_headers('http://www.w3schools.com/php/func_date_strtotime.asp');

The output is this:

0=>HTTP/1.1 200 OK

1=>Connection: close

2=>Date: Thu, 03 May 2012 10:51:00 GMT

3=>Server: Microsoft-IIS/6.0

4=>MicrosoftOfficeWebServer: 5.0_Pub

5=>X-Powered-By: ASP.NET

6=>Pragma: no-cache

7=>Content-Length: 23643

8=>Content-Type: text/html

9=>Expires: Thu, 03 May 2012 10:50:00 GMT

10=>Set-Cookie: ASPSESSIONIDSAARQQST=AAMAAHBBBHBELMHDCHNNLMFP; path=/

11=>Cache-control: no-cache

I read that pragma cache , doesnt necessary mean that the page is uncacheable.

I want to know 2 things: 1) if the page is cached 2) if it was cached 30 days ago.

Can I do this

 $date1=gmdate("D, d M Y H:i:s", strtotime("30 days ago")) . " GMT";
  $date2=$page['Expires'];
  if($date1>$date2)
  {
    echo 'The page was cached for longer than 30 days';
   }
  • 写回答

1条回答 默认 最新

  • dongxin5054 2012-05-03 11:19
    关注

    Since PHP is a server side language you cannot check browser cache(which is a client side) using PHP. So you need some client side scripting like Javascript and not server side programming like PHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制