Performance: Cache configuration
Cache configuration affects how fast data is served by reducing backend calls, improving response time and reducing server load.
@Cacheable("items") public Item getItem(Long id) { return repository.findById(id).orElse(null); }
No caching configured; every request hits the database or backend service directly.| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No cache | N/A | N/A | High backend delay blocks paint | [X] Bad |
| Cache without limits | N/A | N/A | Possible GC pauses cause paint jank | [!] OK |
| Proper cache with limits and preload | N/A | N/A | Fast data delivery, smooth paint | [OK] Good |
getUser(1) is called twice?@Cacheable("users")
public User getUser(int id) {
System.out.println("Fetching user from DB");
return new User(id, "Name" + id);
}@Configuration
@EnableCaching
public class CacheConfig {
@Bean
public CacheManager cacheManager() {
return new CacheManager();
}
}Pass the test and this pattern moves unknown