ç¨äºæä¾å¦æµè§å¨ç¼åæ§å¶ãæ¯å¦å¿
é¡»æsessionå¼å¯ãæ¯æç请æ±æ¹æ³ç±»åï¼GETãPOSTçï¼çï¼è¯¥ç±»ä¸»è¦æå¦ä¸å±æ§ï¼
Set<String> supportedMethodsï¼è®¾ç½®æ¯æç请æ±æ¹æ³ç±»åï¼é»è®¤æ¯æâGETâãâPOSTâãâHEADâï¼å¦ææ们æ³æ¯æâPUTâï¼åå¯ä»¥å å
¥è¯¥éåâPUTâã
boolean requireSession = falseï¼æ¯å¦å½å请æ±å¿
é¡»æsessionï¼å¦ææ¤å±æ§ä¸ºtrueï¼ä½å½å请æ±æ²¡ææå¼sessionå°æåºHttpSessionRequiredExceptionå¼å¸¸ï¼
boolean useExpiresHeader = trueï¼æ¯å¦ä½¿ç¨HTTP1.0åè®®è¿æååºå¤´ï¼å¦ætrueåä¼å¨ååºå¤´æ·»å ï¼âExpiresï¼âï¼éè¦é
åcacheSeconds使ç¨ï¼
boolean useCacheControlHeader = trueï¼æ¯å¦ä½¿ç¨HTTP1.1åè®®çç¼åæ§å¶ååºå¤´ï¼å¦ætrueåä¼å¨ååºå¤´æ·»å ï¼éè¦é
åcacheSeconds使ç¨ï¼
boolean useCacheControlNoStore = trueï¼æ¯å¦ä½¿ç¨HTTP 1.1åè®®çç¼åæ§å¶ååºå¤´ï¼å¦ætrueåä¼å¨ååºå¤´æ·»å ï¼éè¦é
åcacheSeconds使ç¨ï¼
private int cacheSeconds = -1ï¼ç¼åè¿ææ¶é´ï¼æ£æ°è¡¨ç¤ºéè¦ç¼åï¼è´æ°è¡¨ç¤ºä¸åä»»ä½äºæ
ï¼ä¹å°±æ¯è¯´ä¿çä¸æ¬¡çç¼å设置ï¼ï¼
1ãcacheSeconds =0æ¶ï¼åå°è®¾ç½®å¦ä¸ååºå¤´æ°æ®ï¼
Pragmaï¼no-cache // HTTP 1.0çä¸ç¼åååºå¤´
Expiresï¼1L // useExpiresHeader=trueæ¶ï¼HTTP 1.0
Cache-Control ï¼no-cache // useCacheControlHeader=trueæ¶ï¼HTTP 1.1
Cache-Control ï¼no-store // useCacheControlNoStore=trueæ¶ï¼è¯¥è®¾ç½®æ¯é²æ¢Firefoxç¼å
2ãcacheSeconds>0æ¶ï¼åå°è®¾ç½®å¦ä¸ååºå¤´æ°æ®ï¼
Expiresï¼System.currentTimeMillis() + cacheSeconds * 1000L // useExpiresHeader=trueæ¶ï¼HTTP 1.0
Cache-Control ï¼max-age=cacheSeconds // useCacheControlHeader=trueæ¶ï¼HTTP 1.1
3ãcacheSeconds<0æ¶ï¼åä»ä¹é½ä¸è®¾ç½®ï¼å³ä¿çä¸æ¬¡çç¼å设置ã
æ¤å¤ç®å说ä¸ä¸ä»¥ä¸ååºå¤´çä½ç¨ï¼ç¼åæ§å¶å·²è¶
åºæ¬ä¹¦å
容ï¼
HTTP1.0ç¼åæ§å¶ååºå¤´
Pragmaï¼no-cacheï¼è¡¨ç¤ºé²æ¢å®¢æ·ç«¯ç¼åï¼éè¦å¼ºå¶ä»æå¡å¨è·åææ°çæ°æ®ï¼
Expiresï¼HTTP1.0ååºå¤´ï¼æ¬å°å¯æ¬ç¼åè¿ææ¶é´ï¼å¦æ客æ·ç«¯åç°ç¼åæ件没æè¿æåä¸åé请æ±ï¼HTTPçæ¥ææ¶é´å¿
é¡»æ¯æ ¼æå¨æ²»æ¶é´ï¼GMTï¼ï¼å¦âExpires:Wed, 14 Mar 2012 09:38:32 GMTâï¼
HTTP1.1ç¼åæ§å¶ååºå¤´
Cache-Control ï¼no-cache 强å¶å®¢æ·ç«¯æ¯æ¬¡è¯·æ±è·åæå¡å¨çææ°çæ¬ï¼ä¸ç»è¿æ¬å°ç¼åçå¯æ¬éªè¯ï¼
Cache-Control ï¼no-store 强å¶å®¢æ·ç«¯ä¸ä¿å请æ±çå¯æ¬ï¼è¯¥è®¾ç½®æ¯é²æ¢Firefoxç¼å
Cache-Controlï¼max-age=[ç§] 客æ·ç«¯å¯æ¬ç¼åçæé¿æ¶é´ï¼ç±»ä¼¼äºHTTP1.0çExpiresï¼åªæ¯æ¤å¤æ¯åºäºè¯·æ±çç¸å¯¹æ¶é´é´éæ¥è®¡ç®ï¼èéç»å¯¹æ¶é´ã
è¿æç¸å
³ç¼åæ§å¶æºå¶å¦Last-Modifiedï¼æåä¿®æ¹æ¶é´éªè¯ï¼å®¢æ·ç«¯çä¸ä¸æ¬¡è¯·æ±æ¶é´ å¨ æå¡å¨çæåä¿®æ¹æ¶é´ ä¹åï¼è¯´ææå¡å¨æ°æ®æ²¡æåçåå è¿å304ç¶æç ï¼ãETagï¼æ²¡æååæ¶ä¸éæ°ä¸è½½æ°æ®ï¼è¿å304ï¼ã
该æ½è±¡ç±»é»è®¤è¢«AbstractControlleråWebContentInterceptor继æ¿ã
温馨提示:内容为网友见解,仅供参考