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

How do i default to non-cached but still cache? #114

Open
omarmeky opened this issue Jul 15, 2014 · 1 comment
Open

How do i default to non-cached but still cache? #114

omarmeky opened this issue Jul 15, 2014 · 1 comment

Comments

@omarmeky
Copy link

I am interested in using basket.js to cache scripts but I want requested scripts to default to going to the server. In other words, I want to show cached versions of scripts when there is no connection to the internet.

@pavante
Copy link

pavante commented Jul 3, 2015

@omarmeky Well, we also use basket.js in situations, where sometimes there is no internet connection (iPad). The only way we found, was to patch the library in two spots.

  • at the isCacheValid function made sure to check if navigator.onLine. If it is, then we claim that the cache is valid. (but beware if you patch here: the line shouldFetch = isCacheValid(source, obj); is not easy to interpret. seems twisted to me)
  • at the bottom, check if the basket.clear(true) works for you. We removed it, because we felt it removed the cache too early. even if there was no internet connection and the app had no chance to get a fresher version.

Now it works fine for us. Even in offline situations.

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

2 participants