feat: Implement ETag support for app icon caching in GetAppIcon API #11136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
Cache-Control 设置会让图片用缓存不变不更改策略
而Last-Modified设置的值又会在下次请求重新拉取
导致这两个字段冲突,只做到了看似有用的缓存效果。
复现方法:
Summary of your change
换成 etag 方案

一天内在缓存内读取,并保存 etag,一天过期后,请求后端会比对 etag,如果图片没变直接返回 304状态码,不返回内容让浏览器用缓存内容,减少网络传输的时间,同时保证版本更新。
效果:
接口返回的头:
过期后请求 :

后端响应速度:

86400 一天缓存的值可以视情况改动,一般来说app 的 icon 很难变
Please indicate you've done the following: