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

Client Side caching does not work for me. #45

Open
pareshvarde opened this issue Oct 10, 2013 · 11 comments
Open

Client Side caching does not work for me. #45

pareshvarde opened this issue Oct 10, 2013 · 11 comments

Comments

@pareshvarde
Copy link

Client Side caching does not work well in my case.

Attribute I used is

[CacheOutput(ServerTimeSpan=3600, ClientTimeSpan=3600, ExcludeQueryStringFromCacheKey=true)]

as per the document it should cache on client as well. Server caching indeed works great. if you look at attached image it does not fetch data from cache.

cache

@pareshvarde
Copy link
Author

The odd thing I see is that when I do request second time it does not include If-None-Match in header. I understand this might not be an issue and just a question! Please help

@pareshvarde
Copy link
Author

Doing further research I found that when I manually hit request on Request URL:http://localhost/breeze/lfLookups server indeed returns 304 with no data. That is great.

However the breeze.js I am using construct this request dynamically by adding querystring parameter to the request and it becomes like Request URL:http://localhost/breeze/lfLookups?_=1381488654430. The option that has been exposed ExcludeQueryStringFromCacheKey is set so I assume the querystring supplied here should not be an issue. But it don't work! It always returns context with code 200 (OK)

@filipw
Copy link
Owner

filipw commented Oct 11, 2013

there was a bug in ExcludeQueryStringFromCacheKey which is now fixed but not included in the latest nuget package yet. Do you mind building from latest source on Github and seeing if it works with that?

@pareshvarde
Copy link
Author

OK I will try getting latest source. I see that when a querystring parameter changes the client browser do not passes If-None-Match:"VALUE" in request header causing fresh data transfer each time!

@pareshvarde
Copy link
Author

I downloaded latest code and I still cannot get it working! Whenever I change the querystring paramter HTTP header assumes it as a separate resource and do not send If-None-Match:"VALUE" in request header! Is that something your code capable of handling?

@filipw
Copy link
Owner

filipw commented Oct 11, 2013

yes it's handled here https://github.com/filipw/AspNetWebApi-OutputCache/blob/master/src/WebAPI.OutputCache/DefaultCacheKeyGenerator.cs#L21

Also we have tests for that feature, which currently pass. Would you able to provide a small reproduction project? This would be the easiest way to solve this issue

@pareshvarde
Copy link
Author

Thanks for your quick responses and sorry I won't be able provide you sample code at this point. what I have is huge and I might need you to give something simple. see what you can help

@pareshvarde
Copy link
Author

Your querystring ignore code is OK. However we need to set something so that the browser request supplies If-None-Match:"VALUE" when a querystring applied to the request.

I guess browser considers this as a separate resource and does not include this header?

@dmalanij
Copy link
Contributor

dmalanij commented Apr 6, 2017

Coming very late in the game, but @pareshvarde, which browser were you using?
I came across similar things regarding the cache handling done by IE (10 and above) and the browser not sending the if-none-match header, while others (chrome, firefox) do it ok. Unfortunately couldn't find any helpful documentaion on why IE behaves how it does.
I found a workaround and will be sharing some code soon.

@Laoujin
Copy link

Laoujin commented Jan 29, 2018

I've copied dmalanij's code but it doesn't seem to be working on IE11

@Krishna2988
Copy link

Hi,
The client caching is not working, even after setting ClientTimeSpan still the request goes to server and will not get the response from browser cache without server round trip. I am using IE11 browser. Do we need to make any other changes for the client caching to work.

Below is the Decorator configuration,
[CacheOutput(ClientTimeSpan = 120, ServerTimeSpan =60, Private=true, ExcludeQueryStringFromCacheKey =true)]

Below are the response header,
Cache-Control: max-age=60, private

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants