PHP缓存控制似乎不起作用

编程入门 行业动态 更新时间:2024-10-12 20:20:02
本文介绍了PHP缓存控制似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请查看我的网站: vynora

尚未完成。我已将PHP标头放在HTML页面的顶部:

It's not finished. I have put a PHP header in the top of my HTML page:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?> <?php header("Cache-Control: max-age=6000"); ?>

当我去Google的pagespeed时,它告诉我应该优化我的浏览器缓存,请带一个看: Google pagespeed

When I go to pagespeed of Google it tells me that I should optimize my browser cache, please take a look:Google pagespeed

但我已经使用过PHP。那怎么可能呢?

But I already did using PHP. So how is this possible?

推荐答案

问题不在此页面而不在PHP脚本中。请参阅Google的建议:

Problem not in this page and not in PHP scripts. See Google's suggestions:

以下可缓存资源的新生命周期为。在以下资源的期货中指定至少一周的到期日期:

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

  • www.vynora/arrow.png (未指定过期)
  • www.vynora/bing.png (未指定过期)
  • www.vynora/dailymotion.png (未指定过期)
  • http:// www。 vynora/dd_arrow.gif (未指定到期日期)
  • www.vynora/deviantart.png (未指定过期)
  • www.vynora/flickr.png (未指定过期)
  • www.vynora/google.png (未指定过期日期)
  • ...
  • www.vynora/arrow.png (expiration not specified)
  • www.vynora/bing.png (expiration not specified)
  • www.vynora/dailymotion.png (expiration not specified)
  • www.vynora/dd_arrow.gif (expiration not specified)
  • www.vynora/deviantart.png (expiration not specified)
  • www.vynora/flickr.png (expiration not specified)
  • www.vynora/google.png (expiration not specified)
  • ...

这意味着,您应该缓存静态文件。 > 正如我所看到的,你使用的是Apache。在这种情况下,您可以使用 mod_expires

It means, you should cache your static files. As I can see, you use Apache. In this case you can use mod_expires

例如,您可以在此行中添加 .htaccess 文件:

For example, you can add into .htaccess file this lines:

ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" ExpiresByType text/javascript "access plus 86400 seconds" ExpiresByType application/x-javascript "access plus 86400 seconds"

更多推荐

PHP缓存控制似乎不起作用

本文发布于:2023-11-26 08:37:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   不起作用   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!