0

I found this question in StackOverFlow and I can't understand the reason of not caching. I am very new to web programming so i would be glad if someone can answer me this.

  • 1
    If your response is dynamic and always changing you won't want the client to cache it and see an obsolete version of the page. For example [this](https://hookrace.net/time.gif). – Selcuk Aug 12 '21 at 23:44

1 Answers1

2

Here is an example.

User-1 views the count of item-x and sees 1 is still remaining. Backend caches this result for a minute.

enter image description here

Within the next 30 seconds, another User-2 buys the item.

enter image description here

After 30 seconds, User_1 finally decides to buy the item. He views again the stock count, which is the cached value of 1. This is already outdated because another User-2 has already bought item-x a few seconds ago.

enter image description here

Thus, we now have inconsistent data, where the database has 0 count for item-x already while our cache still has the outdated 1 count. User_1 is seeing a value that is not up-to-date.