Subscribe

Close

Thank you for visiting!

Please consider subscribing to the RSS feed or following me on Twitter.

AJAX Get and Cache

Recently I fetched a MVC view with AJAX GET ($.get()) and it worked most of the time in most browsers. However at times I got a cached version of the view.

How to solve this? Easy. Just switch to $.ajax and add cache: false to your AJAX request:

$.ajax({
	url: '/shop/cart',
	cache: false,
	success: function (data) {
		$('#cart').html(data);
	}
});

AJAX calls are by standard GET so there's no need to specify it. Above is enough.

To the top