How to use header() to disable caching in php: 1. Use header() to set the expiration time; 2. Use header() to set the last updated date of the page to today, which can force the browser to obtain the latest information; 3. , use header() to tell the client browser not to use caching.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php prohibits the browser from using cached pages
This can be achieved by sending a specific cache control original HTTP header through PHP's header() function. The specific code is as follows:
<?php //设置此页面的过期时间(用格林威治时间表示),只要是已经过去的日期即可。 header("Expires: Mon, 26 Jul 1970 05:00:00 GMT"); //设置此页面的最后更新日期(用格林威治时间表示)为当天,可以强制浏览器获取最新资料 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //告诉客户端浏览器不使用缓存,HTTP 1.1 协议 header("Cache-Control: no-cache, must-revalidate"); //告诉客户端浏览器不使用缓存,兼容HTTP 1.0 协议 header("Pragma: no-cache"); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to use header() in php to disable caching. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)
