After uploading the picture, the address returned by the background has not changed, resulting in the browser cache not updated?

there is an uploaded image. The background provides an interface to update the image, and the updated address remains the same, so that the new image can be displayed only after the cache has been cleared.

if you have met any friends, please give me some advice.

Thank you very much?

Jan.08,2022

url plus hash


<img src={this.state.url+"?timeStamp="+(+new Date())}/>

add a random number parameter to img's src after submission, similar to http://xxx?random=xxxxxxxx";>


there are several solutions:
1: add a timestamp to the front-end request to force you to bypass the cache. The disadvantage is that there is never caching, which puts pressure on both the client and the server.
2: add the image version number to the database, and + 1 after each update, so that the backend is changed but not much, and the frontend needs to be modified accordingly. This is the plan I used on my side.
3: completely dynamic, so that the server can make a big change, and the client does not need to be reformed. This is the current plan on my side.

Menu