Closed Vidarls closed 8 years ago
That looks like a bug to me. I suspect it might be actually in the lastModified
implementation, which I believe is fixed in the (released very soon) 3.0. There are a couple of suspected bugs lurking in there which are hopefully no longer present.
At this point I think it's probably better to wait a week or so for 3.0, but if it's a significant blocker for you now, I'll see what I can do?
I can live for a week without last-modified :)
Sadly, it seems removing the last-modified did not help, adding just the etag, with no last-modified caused the same error.
Interesting, definitely a bug. I'll take a look and make sure it's not still a bug in 3.0...
I've pushed a new prerelease (b294) of Freya 3 which, I hope, addresses this. Let me know if that helps - more work may be needed, but hopefully that's an improvement!
Thanx, I'll give it a go :-)
So far so good, no more runtime error, and when 200 + new version served. I have not tested the on-non-match query yet, will get back to you once I have
Still getting 304 no matter as long as an etag is provided
Well, better at least in terms of exceptions... Have you got a minimal reproduction case? What are you setting the etag to, and what methods/headers are you trying?
Using:
let handleWithPrivateCache maxAge eTag handler =
let cachingHandler handler =
freya {
do! (Freya.Optic.set Response.Headers.cacheControl_
(Some(CacheControl(
[CacheDirective.Private;
CacheDirective.MaxAge(System.TimeSpan.FromSeconds(maxAge))]))))
do! (Freya.Optic.set Response.Headers.vary_ (Some("Accept Authorization")))
return! handler
}
freyaMachine {
expires (DateTime.UtcNow.AddSeconds(maxAge))
//TODO, etag proper when bug fixed
etag (Freya.map(Strong) eTag)
handleOk (cachingHandler handler)
}
just passing System.Guid.NewGuid().ToString()
as the etag to force a new one each call.
sample request:
GET /my/1/path/2 HTTP/1.1
Host: localhost:44305
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Content-Type: text/plain; charset=utf-8
Accept: */*
DNT: 1
Accept-Encoding: gzip, deflate, sdch
Accept-Language: nb-NO,nb;q=0.8,no;q=0.6,nn;q=0.4,en-US;q=0.2,en;q=0.2,sv;q=0.2
Cookie: [redacted]
If-None-Match: "a6b35e63-e7fa-40f2-a7c7-886165210296"
Response:
HTTP/1.1 304 Not Modified
Expires: Fri, 26 Feb 2016 23:13:11 GMT
ETag: "a6b35e63-e7fa-40f2-a7c7-886165210296"
Server: Microsoft-IIS/10.0
X-SourceFiles: =?UTF-8?B?QzpcU2VjcmV0U3R1ZmZcc3JjXFZldHNlcnZlLldlYi5BcGlcY2xpbmljc1wxMVxzcGVjaWVzXDEw?=
X-Powered-By: ASP.NET
Date: Fri, 26 Feb 2016 23:13:03 GMT
I'll take a look (although probably tomorrow now!)
Does If-Match seem to work as you'd expect (is the problem solely If-None-Match?)
Have not tested, (I actually need to read up on that to see how it is supposed to work..).
But a bit late now
No problem - a bit late for me too! I'll try and pick up tomorrow, and get this sorted :)
Solved, thanx @kolektiv :smile:
This works:
This fails:
I have no idea whether I I'm doing it wrong or if there is a bug
The exception is an
InvalidCastException
: