大网数据广告活动
网站运营与故障问答

Do browsers send different HTTP headers on page reload so that server side caches can be flushed?

· 52CE 我爱测

I'm implementing caching at the server application level, because my hosting doesn't provide Apache caching modules and it's not possible to use a reverse proxy there. Its cheap and fast hosting, so I don't want to change it. Can…

问题原文

原帖链接 · LeonidMew · CC BY-SA 4.0

I'm implementing caching at the server application level, because my hosting doesn't provide Apache caching modules and it's not possible to use a reverse proxy there. Its cheap and fast hosting, so I don't want to change it.

Can I detect when the user presses F5 or Ctrl+F5, instead clicking on link to one page? I'm quite sure there are some special HTTP headers generated on request like this. Without it, the page will be always served from cache.

已采纳解答

原帖链接 · LeonidMew · CC BY-SA 4.0

Browsers do send additional headers, but behavior different. This info in link a bit outdated: stackoverflow question

Looks like Cache-control:no-cache is the best solution, to check for Ctrl+F5, but better to check not the only one header.

Just checked on Firefox Ubuntu, F5 gives nothing, but Ctrl+F5 request contain this

Pragma  no-cache
Cache-Control   no-cache

Checked Chromium - same behavior, same two headers.

This headers may pass any proxy in the middle, and come to end - site server, as I known.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。