Stop Wasting CPU: Declarative Proxy Caching in ODAC.JS
The fastest response is the one your application server never has to handle. In a world where every millisecond counts, rendering the same static HTML template thousands of times per hour isn't just inefficient: it's a waste of expensive compute resources.
Every time a user requests a landing page, a blog post, or a documentation article, your Node.js process wakes up, parses templates, injects variables, and streams a response. For content that rarely changes, this is an architectural tax we decided to eliminate.
Introducing the Proxy Cache API in ODAC.JS. With a single line of declarative code, you can now offload the entire rendering lifecycle to the high-performance ODAC Proxy.
Show Me the Code
In ODAC.JS, performance is a first-class citizen, not an afterthought. Enabling enterprise-grade caching is as simple as telling the framework how long the content should live.
module.exports = function (Odac) {
// Cache this response for 1 hour (3600 seconds)
Odac.cache(3600)
Odac.set('title', 'Welcome to ODAC.JS')
Odac.View.skeleton('main').set('content', 'home')
}
By calling Odac.cache(3600), you are instructing the ODAC Proxy to intercept subsequent requests for this route. Instead of reaching your controller, repeat visitors are served directly from the proxy's optimized memory layer.
The Engineering Behind the Speed
When we designed the Proxy Cache, we wanted to avoid the complexity of manually managing Cache-Control headers or configuring external CDNs. The goal was a "zero-config" experience that remains powerful enough for enterprise scale.
When you call Odac.cache(), ODAC.JS performs a two-pronged header orchestration:
- X-ODAC-Cache: A proprietary internal header that tells the ODAC Proxy exactly how long to store the rendered HTML in its high-speed cache.
- Cache-Control: Standard directives (
public, max-age=...) are automatically calculated and set, ensuring that browser-level caching and downstream CDNs play nicely with your application.

The beauty of this system is that it bypasses the Node.js event loop entirely for cached hits. Your application server stays cool, focused on processing dynamic API requests and complex business logic, while the ODAC Proxy handles the "heavy lifting" of serving static-like content at near-wire speeds.
Smart Invalidation: Safety by Default
We know the biggest fear with caching: serving stale content. The ODAC Proxy includes Smart Invalidation logic built-in.
You don't need to manually purge caches when you deploy a new version of your site. The ODAC Proxy is intelligent enough to detect when underlying view files in the view/ or skeleton/ directories have changed. If a file update is detected, the proxy automatically invalidates the relevant cache entries, ensuring your users always see the latest version of your work without you lifting a finger.

Knowing When to Cache
While the performance gains are massive, Odac.cache() is a specialized tool. It is designed for "Universal HTML" responses: content that looks the same for every visitor.
- ✅ Marketing Pages: Landing pages, features, and pricing.
- ✅ Documentation: Articles and guides that update on deployment.
- ✅ Public Content: Blog posts and news feeds.
- ❌ Dashboards: Anything showing "Welcome, John!" or session-specific data.
- ❌ Authenticated Routes: Pages that change based on user permissions.
ODAC.JS enforces strict safety. If you attempt to pass a non-positive integer or a string to Odac.cache(), it will throw a TypeError immediately. We believe in failing loud and fast during development rather than serving unpredictable results in production.
Zero Boilerplate, Maximum Impact
The philosophy of ODAC.JS has always been about removing the friction between an idea and a high-performance reality. By bringing declarative proxy caching directly into the controller, we've eliminated the need for complex middleware stacks or fragile infrastructure glue code.
Stop rendering the same HTML twice. Start caching with ODAC.JS.