File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "time"
1111
1212 "github.com/jedisct1/dlog"
13+ "github.com/pquerna/cachecontrol/cacheobject"
1314 "golang.org/x/crypto/curve25519"
1415)
1516
@@ -334,23 +335,16 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
334335}
335336
336337func ttlFromHTTPResponse (proxy * Proxy , resp * http.Response ) * uint32 {
337- expiresStr , dateStr := resp .Header .Get ("Expires" ), resp . Header . Get ( "Date " )
338- if len (expiresStr ) == 0 || len ( dateStr ) == 0 {
338+ cacheControlStr := resp .Header .Get ("Cache-Control " )
339+ if len (cacheControlStr ) == 0 {
339340 return nil
340341 }
341- expires , err := http . ParseTime ( expiresStr )
342+ cacheControl , err := cacheobject . ParseResponseCacheControl ( cacheControlStr )
342343 if err != nil {
343344 return nil
344345 }
345- date , err := http .ParseTime (dateStr )
346- if err != nil {
347- return nil
348- }
349- if ! expires .After (date ) {
350- return nil
351- }
352- foundTTL := uint32 (expires .Sub (date ).Seconds ())
353- if foundTTL < proxy .cacheMaxTTL {
346+ foundTTL := uint32 (cacheControl .MaxAge )
347+ if foundTTL < proxy .cacheMinTTL {
354348 foundTTL = proxy .cacheMinTTL
355349 }
356350 if foundTTL > proxy .cacheMaxTTL {
You can’t perform that action at this time.
0 commit comments