PHP设置缓存头
header('Cache-Control: max-age=10'); //设置10秒过期
header("Cache-Control: no-cache, must-revalidate"); //不缓存
htaccess设置缓存
#局部过期:
#请确保LoadModule expires_module modules/mod_expires.so模块开启
<IfModule mod_expires.c>  
  ExpiresActive on
  #Set the default expiry times.
  #ExpiresDefault "access plus 2 days"
  ExpiresByType image/jpg "access plus 1 day"
  ExpiresByType image/svg+xml "access 1 day"
  ExpiresByType image/gif "access plus 1 day"
  ExpiresByType image/jpeg "access plus 1 day"
  ExpiresByType image/png "access plus 1 day"
  ExpiresByType image/webp "access plus 1 day"
  ExpiresByType text/css "access plus 3600 seconds"
  ExpiresByType text/javascript "access plus 3600 seconds"
  ExpiresByType application/javascript "access plus 3600 seconds"
  ExpiresByType image/ico "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 month"
  ExpiresByType text/html "access plus 10 seconds"
</IfModule>  

#完全禁用缓存:
<IfModule mod_headers.c> 	
  Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0" 	
  Header set Pragma "no-cache" 	
  Header set Expires 0 
</IfModule> 
禁用缓存代码2
<FilesMatch "\.(css|gif|htm|html|ico|jpe|jpeg|jpg|webp|svg|js|mp3|mp4|png|pdf|txt)$">
	<IfModule mod_expires.c>
	#ExpiresActive Off
	</IfModule>
	<IfModule mod_headers.c>
		FileETag None
		Header unset ETag
		Header unset Pragma
		Header unset Cache-Control
		Header unset Last-Modified
		Header set Pragma "no-cache"
		Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
	</IfModule>
</FilesMatch>
通过版本号的设置加载新的文件
https://10.1pxeye.com/cache-delete/
延伸阅读

Deep Dive into HTTP Caching: cache-control, no-cache, no-store, max-age, ETag and etc.

Youtube视频。

缓存示意图