createdotnet / API-Documentation

Create. API Documenation
http://developers.create.net/API-Documentation/
0 stars 2 forks source link

Problem with caching? #5

Closed robertoldaker closed 9 years ago

robertoldaker commented 9 years ago

The api seems to cache the results. e.g. If I use one token to get a product feed and then swap to another one its returning the same results.

I turned off all local caching and set the http header value "cache-control" to "no-cache" to force the request to the server but I still had the same results.

What did work however was to add a random, dummy query string value (e.g. "products?random=1234567").

Dayjo commented 9 years ago

Interestingly I cannot replicate this. Is this in the browser (and if so, which browser), or done within code?

In Chrome I used my token to get my products, i.e. go to; https://api.create.net/products. I then changed my token, refreshed the page and the response updated correctly with the other site's products.

Just did that with both of the tokens you're using as well and it appeared to work correctly.

Note; I have no caching headers or anything special set up. Just the token header using ModHeader extension.

robertoldaker commented 9 years ago

I used the c# .net http library. When you make a request it comes back with a boolean saying whether it took it from the local cache or not - it always returned saying it didn't.

How did you use your browser for this (apologies for my ignorance)? I am not sure how to set http header values. Would be a good test as it would show whether the client library is at fault.

On 16 January 2015 at 14:48, Joel notifications@github.com wrote:

Interestingly I cannot replicate this. Is this in the browser (and if so, which browser), or done within code?

In the browser I used my token to get my products, i.e. go to; https://api.create.net/products. I then changed my token, refreshed the page and the response updated correctly with the other site's products.

Just did that with both of the tokens you're using as well and it appeared to work correctly.

— Reply to this email directly or view it on GitHub https://github.com/createdotnet/API-Documentation/issues/5#issuecomment-70263322 .

Dayjo commented 9 years ago

Hi Rob,

There's an extension for Chrome called PostMan which is pretty useful for REST API testing; https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

But for just using url based calls, I use a Chrome extension called ModHeader to set my token like so;

robertoldaker commented 9 years ago

Thanks for that - they sound useful extensions!

On 16 January 2015 at 14:59, Joel notifications@github.com wrote:

There's an extension for Chrome called PostMan which is pretty useful for REST API testing; https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

But for just using url based calls, I use a Chrome extension called ModHeader https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en to set my token like so;

https://camo.githubusercontent.com/7616de0880510af9a4690aad83f3e6bc321b956c/687474703a2f2f636c2e6c792f696d6167652f3251334a3432324b304232612f496d616765253230323031352d30312d31362532306174253230322e35392e3038253230706d2e706e67

— Reply to this email directly or view it on GitHub https://github.com/createdotnet/API-Documentation/issues/5#issuecomment-70265001 .

Dayjo commented 9 years ago

No problem! Let me know if you get the same response doing it this way!

robertoldaker commented 9 years ago

Have tried them using chrome and there seems no caching issues - obviously something to do with my client!

On 16 January 2015 at 15:01, Robert Oldaker roldaker@gmail.com wrote:

Thanks for that - they sound useful extensions!

On 16 January 2015 at 14:59, Joel notifications@github.com wrote:

There's an extension for Chrome called PostMan which is pretty useful for REST API testing; https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

But for just using url based calls, I use a Chrome extension called ModHeader https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en to set my token like so;

https://camo.githubusercontent.com/7616de0880510af9a4690aad83f3e6bc321b956c/687474703a2f2f636c2e6c792f696d6167652f3251334a3432324b304232612f496d616765253230323031352d30312d31362532306174253230322e35392e3038253230706d2e706e67

— Reply to this email directly or view it on GitHub https://github.com/createdotnet/API-Documentation/issues/5#issuecomment-70265001 .

robertoldaker commented 9 years ago

I have tried two different http clients on ASP.NET - the official one and a third party one specific for REST apis. They both have an issue with caching that can only be fixed by adding a dummy query value with a random value.

Would it be possible to add a http header with name "Cache-Control" and value of "no-cache" to the response?

Dayjo commented 9 years ago

Hi @robertoldaker,

We've added no-cache to the header, see if that helps!

robertoldaker commented 9 years ago

Is this mod live?

On 19 January 2015 at 11:10, Joel notifications@github.com wrote:

Reopened #5 https://github.com/createdotnet/API-Documentation/issues/5.

— Reply to this email directly or view it on GitHub https://github.com/createdotnet/API-Documentation/issues/5#event-220900882 .

Dayjo commented 9 years ago

Yeah this is live. Here are the headers I now get;

Accept-Ranges:bytes
Age:0
Cache-Control:no-cache
Connection:keep-alive
Content-Encoding:gzip
Content-Length:3542
Content-Type:application/json
Date:Mon, 19 Jan 2015 11:22:57 GMT
Server:nginx/0.7.67
Vary:Accept-Encoding
Via:1.1 varnish
X-Backend:webnode02
X-Varnish:301043276
robertoldaker commented 9 years ago

Still getting the caching problem.

Will revert to adding the dummy query variable for want of a better solution.

Must be something low-level in .Net that is shared by both client libraries.

On 19 January 2015 at 11:24, Joel notifications@github.com wrote:

Yeah this is live. Here are the headers I now get;

Accept-Ranges:bytes Age:0 Cache-Control:no-cache Connection:keep-alive Content-Encoding:gzip Content-Length:3542 Content-Type:application/json Date:Mon, 19 Jan 2015 11:22:57 GMT Server:nginx/0.7.67 Vary:Accept-Encoding Via:1.1 varnish X-Backend:webnode02 X-Varnish:301043276

— Reply to this email directly or view it on GitHub https://github.com/createdotnet/API-Documentation/issues/5#issuecomment-70479158 .

Dayjo commented 9 years ago

Must be! Have tried via HTTPS in-browser, and through PHP with no issues with caching.

Potentially could add a last-modified header, but no-cache should do the job if you've got local caching.