ServiceStack/src/ServiceStack.Extensions/NodeProxy.Usage.md
The NodeProxy class now includes intelligent in-memory caching with configurable size limits to optimize performance when proxying to Node.js applications.
var proxy = new NodeProxy("http://localhost:3000");
// Uses default: 5 MB per file, 100 MB total cache
var proxy = new NodeProxy("http://localhost:3000")
{
MaxFileSizeBytes = 10 * 1024 * 1024, // 10 MB per file
MaxCacheSizeBytes = 200 * 1024 * 1024, // 200 MB total cache
Verbose = true // Enable cache logging
};
var proxy = new NodeProxy("http://localhost:3000")
{
MaxFileSizeBytes = 1 * 1024 * 1024, // 1 MB per file
MaxCacheSizeBytes = 25 * 1024 * 1024, // 25 MB total cache
};
var proxy = new NodeProxy("http://localhost:3000")
{
MaxFileSizeBytes = 512 * 1024, // 512 KB per file (skip large bundles)
MaxCacheSizeBytes = 50 * 1024 * 1024, // 50 MB total cache
};
Monitor cache performance:
var stats = proxy.GetCacheStats();
Console.WriteLine($"Cache Hits: {stats.hits}");
Console.WriteLine($"Cache Misses: {stats.misses}");
Console.WriteLine($"Hit Rate: {stats.hitRate:P2}");
Console.WriteLine($"Entries: {stats.entryCount}");
Console.WriteLine($"Total Size: {stats.totalSize / 1024 / 1024} MB");
proxy.ClearCache();
proxy.RemoveCacheEntry("/static/bundle.js");
GET /?clear=all // Clear entire cache
GET /path/to/file?clear // Clear specific file
MaxFileSizeBytes are never cachedMaxCacheSizeBytes, the least recently used entries are evictedLastAccessTime for LRU trackingvar proxy = new NodeProxy("http://localhost:3000")
{
ShouldCache = (context) => false // Never cache
};