Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

304 with etag matching on cache miss #136

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions proxies/proxies.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Raise-Fault-Not-Modified">
<DisplayName>Raise Fault Not Modified</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<Payload/>
<StatusCode>304</StatusCode>
<ReasonPhrase>Not Modified</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
14 changes: 0 additions & 14 deletions proxies/remote-proxy-gcp/apiproxy/policies/Send-Not-Modified.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Headers>
<Header name="Cache-Control">no-store</Header>
<Header name="Pragma">no-cache</Header>
<Header name="ETag">{cachedETag}</Header>
<Header name="ETag">{response.header.etag}</Header>
</Headers>
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">@productlist#</Payload>
</Set>
Expand Down
10 changes: 5 additions & 5 deletions proxies/remote-proxy-gcp/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
<Step>
<Name>Lookup-Products</Name>
</Step>
</Request>
<Response>
<Step>
<Name>Parse-Product-Cache</Name>
<Condition>lookupcache.Lookup-Products.cachehit = true</Condition>
</Step>
</Request>
<Response>
<Step>
<Name>Create-New-Response</Name>
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
Expand All @@ -108,12 +108,12 @@
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
</Step>
<Step>
<Name>Send-Not-Modified</Name>
<Condition>(lookupcache.Lookup-Products.cachehit = true) and (etag = cachedETag)</Condition>
<Name>Raise-Fault-Not-Modified</Name>
<Condition>etag = response.header.etag</Condition>
</Step>
<Step>
<Name>Send-Product-List</Name>
<Condition>(lookupcache.Lookup-Products.cachehit = true) and (etag != cachedETag)</Condition>
<Condition>lookupcache.Lookup-Products.cachehit = true</Condition>
</Step>
</Response>
<Condition>(proxy.pathsuffix MatchesPath "/products") and (request.verb = "GET")</Condition>
Expand Down
2 changes: 1 addition & 1 deletion proxies/remote-proxy-gcp/apiproxy/remote-service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<Policy>Products-Callout</Policy>
<Policy>Products-to-JSON</Policy>
<Policy>Raise-Fault-Missing-Secret</Policy>
<Policy>Raise-Fault-Not-Modified</Policy>
<Policy>Raise-Fault-Unknown-Request</Policy>
<Policy>Send-JWKs-Message</Policy>
<Policy>Send-Not-Modified</Policy>
<Policy>Send-Product-List</Policy>
<Policy>Send-Version</Policy>
<Policy>Set-Product-Cache</Policy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ try {

// set variables for response
context.setVariable("productlist", prodcache.productlist);
context.setVariable("cachedETag", prodcache.etag);
context.setVariable("response.header.etag", prodcache.etag);
} catch (e) {
throw 'Error in parse-product-cache javascript execution';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Raise-Fault-Not-Modified">
<DisplayName>Raise Fault Not Modified</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<Payload/>
<StatusCode>304</StatusCode>
<ReasonPhrase>Not Modified</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Headers>
<Header name="Cache-Control">no-store</Header>
<Header name="Pragma">no-cache</Header>
<Header name="ETag">{cachedETag}</Header>
<Header name="ETag">{response.header.etag}</Header>
</Headers>
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">@productlist#</Payload>
</Set>
Expand Down
10 changes: 5 additions & 5 deletions proxies/remote-proxy-legacy/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@
<Step>
<Name>Lookup-Products</Name>
</Step>
</Request>
<Response>
<Step>
<Name>Parse-Product-Cache</Name>
<Condition>lookupcache.Lookup-Products.cachehit = true</Condition>
</Step>
</Request>
<Response>
<Step>
<Name>JavaCallout</Name>
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
Expand All @@ -100,12 +100,12 @@
<Condition>lookupcache.Lookup-Products.cachehit = false</Condition>
</Step>
<Step>
<Name>Send-Not-Modified</Name>
<Condition>(lookupcache.Lookup-Products.cachehit = true) and (etag = cachedETag)</Condition>
<Name>Raise-Fault-Not-Modified</Name>
<Condition>etag = response.header.etag</Condition>
</Step>
<Step>
<Name>Send-Product-List</Name>
<Condition>(lookupcache.Lookup-Products.cachehit = true) and (etag != cachedETag)</Condition>
<Condition>lookupcache.Lookup-Products.cachehit = true</Condition>
</Step>
</Response>
<Condition>(proxy.pathsuffix MatchesPath "/products") and (request.verb = "GET")</Condition>
Expand Down
2 changes: 1 addition & 1 deletion proxies/remote-proxy-legacy/apiproxy/remote-service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<Policy>Products-to-JSON</Policy>
<Policy>Raise-Fault-Invalid-API-Key</Policy>
<Policy>Raise-Fault-Missing-JWKS</Policy>
<Policy>Raise-Fault-Not-Modified</Policy>
<Policy>Raise-Fault-Unknown-Request</Policy>
<Policy>Send-JWKs-Message</Policy>
<Policy>Send-Not-Modified</Policy>
<Policy>Send-Product-List</Policy>
<Policy>Send-Version</Policy>
<Policy>Set-Product-Cache</Policy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ try {

// set variables for response
context.setVariable("productlist", prodcache.productlist);
context.setVariable("cachedETag", prodcache.etag);
context.setVariable("response.header.etag", prodcache.etag);
} catch (e) {
throw 'Error in parse-product-cache javascript execution';
}