❔ HttpResponse CacheHeaders
I have two questions. Why is this list only returning one item? Also, the server gives me
public max-age
and sometimes it is max-age
. Will Headers.CacheControl.MaxAge
work with both?15 Replies
Why is this list only returning one item?Which list, exactly?
var a
only has one item in it.FirstOrDefault
Do you know what that does?
ooff okay, lool
forest through the trees...
Also, if it returns
null
, that .Value
will throw an exceptionyeah I was thinking that too.
Actually what is the reason to call ToList in this code?
Only question left is the
public max-age
and max-age
. Do they both show up under Headers.CacheControl.MaxAge
var a is just a testI'm not sure where you are seeing
public max-age
Sometimes the server gives me one or the other. I don't know the difference.
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.headers.cachecontrolheadervalue.public?view=net-7.0
This property represents the "public" directive in a cache-control header field on an HTTP response.So the
public
shows up as Headers.CachControl.Public
being true/falseOooohhhh so the cache control header is one string, and the sub headers are just parsed out of it. got it
The
public
and max-age
are called directives: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#cache_directives
And yeah, they're parsed out separatelyCool thanks. I was doing this wrong. Glad to know.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.