Search code examples
jqueryajaxruby-on-rails-3cachingtokenize

Is there a way to prevent caching of certain URLs?


I have an auto complete box on my site. I'm using Tokeninput. When there isn't a result I have users click a link to add it. The problem is that if they've already typed the exact query that's already been cached, so they have to refresh the page to see the result in the drop down. Is there anyway to prevent caching of certain ajax calls?


Solution

  • Set the cache option in jQuery.ajax to false. This will prevent the caching of AJAX calls. It works by adding a new query-string parameter called _, which is set to the current timestamp.