Comments (2)
Hey. The readme was copied from the original library and was largely unchanged.
The default cache function is defined as follows so your fallback would not work as shrinkRay.cache
is undefined:
Line 78 in 2eac9a7
And as for providing examples, I really don't see much of a point:
- Given how
req
+res
are standard abbreviations for request + response and how the README uses those variable names, it's clear what data the function can work with. - The caching criteria would vary wildly from application to application; we might end up confusing the user even more if they are unable to get past the previous point.
A working version of the example you gave would look like this in its simplest form:
function shouldCache(req) {
return req.url.startsWith('/static');
}
from shrink-ray.
Part of the confusion was my fault, I was unsure that if I didn't fall back to standard cache function I would cache files without etag or something equivalently bad. I was afraid my function would override some desired behavior but with your response and a more careful reading of the docs I see that I can return true from my override cache function without fear:
shrink-ray ... will never cache a response that does not include an ETag, even if the cache function returns true.
Phew. Thanks for your help!
from shrink-ray.
Related Issues (20)
- An in-range update of compressible is breaking the build 🚨 HOT 1
- An in-range update of node-zopfli-es is breaking the build 🚨 HOT 2
- An in-range update of @types/node is breaking the build 🚨 HOT 1
- An in-range update of accepts is breaking the build 🚨 HOT 1
- An in-range update of @types/node is breaking the build 🚨 HOT 1
- Prefer zlib over zopfli for gzip? HOT 7
- Fails to install on node 12 macos HOT 2
- An in-range update of @types/node is breaking the build 🚨 HOT 3
- An in-range update of @types/node is breaking the build 🚨 HOT 3
- An in-range update of compressible is breaking the build 🚨
- GZIP fallback HOT 5
- Likely memory leak HOT 10
- Types: ShrinkRayOptions.filter should be optional
- Cache: only re-encode if maximum quality wasn't used originally HOT 1
- TypeError: this._implicitHeader is not a function HOT 1
- replace node-zopfli-es by node-zopfli HOT 1
- Node v16.2.0 Fails To Install Shrink-Ray-Current On Windows 10 HOT 3
- Lots of deprecated sub-dependencies HOT 1
- Brotli zlib.constants.BROTLI_MIN_QUALITY defaults to BROTLI_DEFAULT_QUALITY
- Comma is inserted into the encoded text
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shrink-ray.