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

Cache doesn't seem to work #18

Closed
Ideallia opened this issue Jan 22, 2017 · 5 comments
Closed

Cache doesn't seem to work #18

Ideallia opened this issue Jan 22, 2017 · 5 comments
Labels

Comments

@Ideallia
Copy link

Hello, I've implemented the cache service like in the documentation in this repo.
But when I try to reopen the page in my app several times, it's continuesly making a new http request instead of returning the cached data.
When I try to inspect my app with Safari I see that it's building a cache in the database under "Storage", but when trying to view the data Safari is not responding anymore and I have to restart Safari again.
Am I doing something wrong?

// Constructor
this.cacheService.setDefaultTTL(60 * 60);

// GET-request
let request = this.http.get(this.config.getApi().getUrl() + endpoint, this.getHeaders(this.token));
        return this.cacheService.loadFromObservable(endpoint, request)
        .map((response: Response) => {
            return this.getResponse(response);
        })
        .catch(response => {
            return Rx.Observable.throw(response.json().message || 'A server communication error has been throwed.');
        });

The same request for several times in a few seconds. The time to load the response is getting worse instead of better when reloading the page.
schermafbeelding 2017-01-22 om 23 03 15

@Nodonisko
Copy link
Owner

Nodonisko commented Jan 23, 2017

Thank you for submitting issue! Did you tried this with different endpoint? Maybe there is some problem related to big size of your response and WebSQL. I will try to debug it, but maybe it will tooks me weeks or two...

You can also try this code:

// Constructor
this.cacheService.setDefaultTTL(60 * 60);

// GET-request
let request = this.http.get(this.config.getApi().getUrl() + endpoint, this.getHeaders(this.token))        .map((response: Response) => {
            return this.getResponse(response);
        });
        return this.cacheService.loadFromObservable(endpoint, request)
        .catch(response => {
            return Rx.Observable.throw(response.json().message || 'A server communication error has been throwed.');
        });

@Ideallia
Copy link
Author

Yes, I also tried it with other endpoints. Some of the endpoints return a quite large dataset (like the example above), but there are also endpoints which return a small dataset (f.e. 1 record).
I think it could also be related with to the newest versions of Ionic.
I'm running Ionic v2.0.0.-rc4. It looks like that since upgrading to this version and an upgrade to v1.1.1 of your plugin (apostrophe fix), your cache plugin doesn't seem to work anymore like expected.
If you need more information, I'd like to help you investigating the issue.

@Nodonisko
Copy link
Owner

Maybe its releated to #17

Did you tried older version? Can you try version before apostrophe fix? And what about Chrome or other browsers?

I will try to investigate problem myself soon as possible.

@Nodonisko Nodonisko added the bug label Jan 23, 2017
@Nodonisko
Copy link
Owner

Can you test latest version?

@Nodonisko
Copy link
Owner

Should be fixed in latest version.

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

No branches or pull requests

2 participants