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

clearPrefetchCache Doesn't Always Work #771

Closed
ghost opened this issue Mar 13, 2014 · 6 comments
Closed

clearPrefetchCache Doesn't Always Work #771

ghost opened this issue Mar 13, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2014

If the prefetch has no cacheKey and the URL contains special regex characters, such as '?' or '()', clearPrefetchCache has no effect.

In http://jsfiddle.net/8qass/4/ you can click on localStorage to list the keys, click on clearPrefetchCache to call the method, click on localStorage to see the keys are still there. However, if you give prefech a (regex safe) cacheKey, it works as expected.

@jharding
Copy link
Contributor

Nice catch, I'll make sure this gets fixed for the next release.

@jharding
Copy link
Contributor

In case anyone wants to help out and submit a pull request, this is the line causing the issue. Regex characters in the prefix need to be escaped. That can be done with _.escapeRegExChars.

@jharding jharding added this to the v0.10.3 milestone Mar 13, 2014
@mokesmokes
Copy link

Just adding my 2 cents: clearPrefetchCache is quite misleading IMO, since it only clears the persistent cache for a specific url or cacheKey. I'm guessing that most users actually intend on blowing away the entire prefetch cache, and not that for a specific URL. Or at the very least, have an option to clear either. I propose adding a universal prefix such as __Bhound to the existing prefix, thus enabling clearing all prefetch entries from the cache.

@jharding
Copy link
Contributor

I disagree with that. If I were to call clearPrefetchCache on a bloodhound instance, I wouldn't expect cached data for other bloodhounds to be removed.

Still, it might be useful to prefix all keys with a universal bloodhound prefix so that you could do something like this.

@mokesmokes
Copy link

We're still talking about Bloodhound instances belonging to the same app, and the number of different prefetches over time could be huge, thus the need to clean every once in a while. Would be nice to have both options available.

@jharding jharding modified the milestones: v0.10.3, v0.10.4 Jul 8, 2014
@jharding
Copy link
Contributor

jharding commented Jul 8, 2014

Fixed for v0.10.3.

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

No branches or pull requests

2 participants