求教cache-control头的控制(影响了自己写的缓存功能了)
自己做了一个php控制的缓存,依靠etag和文件缓存来处理
如果浏览器发送了etag,则进行对比,etag一致,直接发送304,etag不一致,如果有文件缓存,则直接读取文件缓存,并发送当前服务器缓存的etag
(文件缓存和etag的更新在其他地方处理)
现在突然发现有响应没有返回304,一查,发现这个地址的服务器http响应头返回了cache-control:no-cache
我清空服务器的缓存后看,第一次响应的时候服务器就自动发送了一个no-cache头,(我的etag也发送了出去的),结果就是无论服务器端有没有缓存,浏览器都不会把etag添加到自己的请求头里面去,服务器端处理的时候没有收到etag,就当做是第一次请求,然后又重新读取文件缓存,又重新发送etag……(响应200)
大致是这么回事,但是这样就失去了我想用304来直接缓存的效果了。
看了一下区别,正常的数据,大概10KB,运行一直正常(没有缓存初次请求130ms,有缓存初次请求90ms,之后16ms或以下)
而没有发送304的这个(一直发送no-cache)的这个,数据只有304B,(但是就算不加缓存模块,因为服务器计算的原因,也要花90ms左右),
怀疑是不是因为数据返回不一致的原因而导致的,将这个304B的数据扩增到12KB,还是发送no-cache头,增加到20kb,也是一样的。
然后懵了……不知道怎么回事了。
(天地良心,代码全部是我写的,除了一个header(etag)外绝对没有发送其他的etag了)
------解决思路----------------------
原因是什么?
为什么会一直发送no-cache呢?估计是服务器设置了吧。

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


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

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
