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

A flag to prevent caching #562

Closed
krazyjakee opened this issue Dec 16, 2013 · 13 comments
Closed

A flag to prevent caching #562

krazyjakee opened this issue Dec 16, 2013 · 13 comments
Milestone

Comments

@krazyjakee
Copy link

In our search results we would like to include pseudo-results.

For example:

  • Game 1
  • Game 2
  • Game 3
  • Also found 9 movies <-- pseudo
  • Also found 8 music tracks <-- pseudo

The problem is that it is also caching these locally and intruding on other searches. Is it possible to prevent caching but only for those items?

@jharding
Copy link
Contributor

I'll look to make request caching something that's configurable for v0.10.1.

@simplenotezy
Copy link

+1 for a way to clear cache. Or even better scenario:

On page load:

  1. Showing the cached results instantly - just like it does now
  2. Queries the prefetch URL
  3. When results are loaded, it replaces the newly loaded content, with the prefetched.

This is important in case when you add new content to the results, after it is cached - it will simply not show up.

Is this possible? What do you think of it @jharding ?

@furioursus
Copy link

Yet another +1. My client is using typeahead to show hotel listings quickly and easily for a search/navigation tool, but since they update daily, results aren't seen immediately. Is there any sort of expected timeline for 0.10.1?

@jharding
Copy link
Contributor

jharding commented Feb 2, 2014

@onebrightlight are you talking about prefetch caching?

@edukarma
Copy link

edukarma commented Feb 4, 2014

I am pretty sure he does, and so am I. I don't know whether my solution is best-practice/doable, but I find it quite good. It will allow instant results, and the (eventually) new results will be updated async.

What do you think of it?

@jharding
Copy link
Contributor

jharding commented Feb 4, 2014

What's your solution @edukarma? The one suggested by @canfiax? I think that's a solid solution and I wouldn't be opposed to implementing something along those lines.

@krazyjakee
Copy link
Author

#521
Although I don't see this as an optimal solution for my problem of adding ever-changing pseudo-items (see first post), it is a workaround.

Is there a way to flag specific cached items to not be cached?
I see an object "requestCache.cache" presumably there is sorted items in there that could be removed or?

Thanks.

@jharding
Copy link
Contributor

jharding commented Feb 8, 2014

@krazyjakee just to be clear, are you using remote or prefetch? Just want to make sure I understand your problem.

@krazyjakee
Copy link
Author

We are using remote.

@jharding
Copy link
Contributor

jharding commented Mar 9, 2014

FYI I decided against adding a flag for preventing the caching of remote responses, instead I've added Bloodhound#clearRemoteCache that offers a way to programmatically clear the remote responses cache. This will be going out in v0.10.2.

@simplenotezy
Copy link

Nice! Will it also be possible to clear the prefetched data? For instance, I use typeahead as a Wordpress plugin to search your pages. I am currently avoiding using prefetch, even though it would be the best solution. If you edited a page name, or simply created a new, it would not show up in results.

@jharding
Copy link
Contributor

Yep, take a look at #703 for more details.

@f0xtrot
Copy link

f0xtrot commented Jun 30, 2014

When creating the instance for typahead, create a unique 'name' value.

var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
var randomUniqueId = randLetter + Date.now();

$('.class').typeahead({
name: 'name-' + randomUniqueId,
prefetch: '/json/ourdata.json'
});

This is not preventing caching, but instead will create a semi unique name for typeahead new instances. The above randomUniqueId code will not prevent collision and is not 100% unique, but you get the idea.

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

No branches or pull requests

6 participants