C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • WebSockets
  • Task Scheduling
  • Queues
  • Job Batches
  • Caching
  • Events
  • Broadcasting
  • Notifications
  • SMS Channels
  • File Storage
  • Payment
  • Search
  • Security
  • Security Comparison
  • Performance
  • HTTP/2 Support
  • Deployment
Advanced

AutoCache

CanxJS includes an intelligent "AutoCache" system that learns from traffic patterns and automatically caches slow, frequent GET requests.

How it Works

The PatternAnalyzer monitors your incoming requests. If a specific GET route is accessed frequently (high hits) and has a high average response time (>100ms), AutoCache marks it as "cacheable" and begins serving it from memory.

Configuration

src/app.ts
1import { createApp, autoCacheMiddleware } from "canxjs";
2
3const app = createApp();
4
5// Enable AutoCache
6// It automatically detects frequent, slow GET requests and caches them.
7app.use(autoCacheMiddleware({
8 enabled: true,
9 defaultTtl: 300, // 5 minutes
10 exclude: ['/api/auth/*', '/api/admin/*']
11}));

Manual Management

Terminal
# Clear all caches
bun run canx cache:clear
# Optimize (includes cache clear)
bun run canx optimize

Next Steps

Ensure your app is secure.