cachecontrol icon indicating copy to clipboard operation
cachecontrol copied to clipboard

Consider adding strict parsing as an option

Open mbyczkowski opened this issue 8 years ago • 1 comments

I've been dealing with some parsing issues as some servers don't conform to HTTP Caching spec. Since the error vars are exported I could I just handle it in my code, but it seems to me that having something like this:

cachecontrol.CachableResponse(req, res, cachecontrol.Options{StrictParsing: false})

would be pretty beneficial. Then, these are errors could be ignored and defaults would be assumed for the fields:

ErrQuoteMismatch
ErrMaxAgeDeltaSeconds 
ErrMaxStaleDeltaSeconds
ErrMinFreshDeltaSeconds
ErrNoCacheNoArgs
ErrNoStoreNoArgs
ErrNoTransformNoArgs
ErrOnlyIfCachedNoArgs
ErrMustRevalidateNoArgs
ErrPublicNoArgs
ErrProxyRevalidateNoArgs

mbyczkowski avatar Dec 16 '17 00:12 mbyczkowski

Do you think "errors" should be treated as a reason for non-cachability?

eg, extend https://godoc.org/github.com/pquerna/cachecontrol/cacheobject#Reason

ReasonErrQuoteMismatch.

Otherwise I think the main APIs would need to be revised to have a separate way for returning specific parse errors?

pquerna avatar Dec 16 '17 04:12 pquerna