Performance: Why caching matters for performance
HIGH IMPACT
Caching reduces the time to deliver data by avoiding repeated processing or database calls, improving page load and responsiveness.
@Cacheable("dataCache") public String getData() { // fetch once, then cache return database.query("SELECT * FROM data"); }
public String getData() {
// fetch from database every time
return database.query("SELECT * FROM data");
}| Pattern | Backend Processing | Network Delay | Response Time | Verdict |
|---|---|---|---|---|
| No caching, fetch every time | High (database query each request) | Medium | Slow (100+ ms) | [X] Bad |
| Caching with @Cacheable | Low (cache hit after first) | Low | Fast (<10 ms) | [OK] Good |