PHP禁止页面缓存的代码_php技巧
核心代码:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pramga: no-cache");
这对于某些页面来说是很有用的,例如:验证码,因为每次生成的验证码必须不同,否则验证码就没有任何意义了,这就可以用上面的语句实现禁止缓存。
再比如:“ 每回贴一次就换一个美女图片”,必须禁止页面缓存,否则返回的是缓存中相同的图片。
最近看到百度联盟上的《联盟志》-“如何让网民爱上你的网站”(主要是讨论如何提高用户体验的)联想到一点:
以论坛为例,当用户登陆后显示的是登陆后的 页面例如“管理”、“修改资料”等,当用户退出论坛后,再次返回刚才的页面,
仍然有“管理”、“修改资料”等(因为返回的是 缓存页面),虽然这时候cookie已经清空,“管理”、“修改资料”等已经不起作用了,
但是用户仍然以为这是有效的页面,从而认为别人也可以“管 理”、“修改资料”等,以为网站是不安全的(虽然实际上是安全的)。这时候在需要cookie验证的页面上加上上面的代码就有很用了,至少可以消除对于用户心 理的不良影响。

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



The chat method provided in the WeChat app is very simple. You can chat anytime and anywhere. All chats are free of charge, creating a comfortable and relaxed social atmosphere. You can interact and chat wherever you go, so you won't feel bored all day long. Download a lot of interesting emoticons and kaomojis for free. Enter your mobile phone number to log in online and interact and chat with friends and family online. No matter how far away you are, you can contact each other immediately and open a dialog box to communicate easily. Of course, sometimes you You may also enter a group chat you don’t know for no reason. Of course, you are not interested in this group. You can also set it up to prevent others from dragging you in. The chat will be much better. Now the editor is online to provide detailed settings for WeChat users one by one. How to prevent others from dragging me into group chats. 1The first step

What is "RedditisFunErrorForbidden"? Reddit is an interesting application with error-free messages that are commonly found on websites and social forums. This error pops up when a user tries to access certain areas or perform specific actions on the platform without the required permissions. The platform is a large online forum with many smaller forums and different ways for users to interact. It has certain rules and restrictions to keep things safe and orderly. What is the reason for "Reddit is banned for funny bug"? Understanding the problem will help users identify common causes. Here are some common causes of errors. Private subreddits: If the subreddit you are trying to access is set to private, you will need to

Under certain circumstances, strictly restricting users from making any adjustments to time can ensure that the various data generated during the entire system operation remain accurate and inherently stable and consistent. However, although many users are not clear on how to implement this time limit on Windows 10 Home Edition computers, you can still refer to the following detailed steps to implement this specification requirement. Win10 Home Edition prohibits time modification. Method 1. Press win+ RThen select "Run" 2. Enter "secpol.msc" 3. Click "Local Policy" - "User Rights Assignment" 4. Double-click on the right to open "Change System Time" 5. Select the user name, click Delete, click Apply and Confirm to complete the setting

ChatGPT has become popular around the world recently, and everyone has surrendered to the powerful functions of artificial intelligence. Little did they know that this thing has been widely used in the sports circle a long time ago and has effectively improved sports levels. We are all amazed at how SAOT technology has changed the direction of the competition at the 2022 Qatar World Cup. In fact, the technology of multi-camera camera locking and sensor positioning has been applied as early as the Tokyo Olympics 2 years ago. Omega spent 4 years developing its own AI vision system that can effectively track the ball's position and simulate the ball's trajectory like Eagle Eye technology. Relying on sensors inside the ball and multi-camera cameras to capture at 250 frames per second, the system has an accuracy rate of over 99% in beach volleyball. This has changed from the past when referees relied on naked eyes and video.

Friends, do you know how to prevent the hard drive from entering hibernation in the Mac system? Today I will explain how to prevent the hard drive from entering hibernation in the Mac system. If you are interested, please come and take a look with me. I hope it can help you. Step 1: After opening the computer system preferences, click Energy Saving (as shown in the picture). Step 2: After opening the energy saving page, click Power (as shown in the picture). Step 3: On the power settings page, uncheck the option "Put the hard drive into hibernation if possible" (as shown in the picture).

How to implement data caching and page caching through the Webman framework? Webman is a Python-based Web framework that is lightweight, flexible, easy to use, and supports a variety of plug-ins and extensions. In web development, implementing data caching and page caching is one of the important means to improve website performance and user experience. In this article, we will explore how to implement data caching and page caching through the Webman framework and give corresponding code examples. 1. Data cache Data cache is to cache some frequently accessed data

When using Douyin software, our accounts will be searched by unfamiliar users. The following will introduce to you how to prevent strangers from being searched. 1. After opening the Douyin APP on your mobile phone, click "I" in the lower right corner of the page to switch. Click the three horizontal lines icon in the upper right corner of the page to open the menu window, then find and click the "Settings" function to open it. 3. There is a "Privacy Settings" on the settings page, click on it to enter. 4. Click "Find my way" on the privacy settings page. 5. After entering the new interface, click on the current settings behind the item "Can be searched by strangers" to enter. 6. A window will pop up at the bottom of the page. Click the switch button behind "Can be searched by strangers". When the button is set to gray

Golang is an efficient, concise, and reliable programming language that is increasingly used in web applications. In order to optimize the performance of web applications, developers usually need to use caching technology to reduce resource access and improve application response speed. In Golang, data caching, result caching and page caching are commonly used caching technologies. In this article, we will understand the purpose and usage of these 3 caching technologies. 1. Data caching Data caching refers to storing frequently accessed data in memory to improve
