Welcome Guest, Not a member yet? Register   Sign In
Jquery & Codeigniter ajax cache: false
#1

[eluser]mjsilva[/eluser]
Hi there,

TIL that Internet Explorer caches every ajax call, even if you do something like this:

Code:
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
$this->output->set_header('Expires: '.gmdate('D, d M Y H:i:s', time()).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

In Jquery you can specify this:

Code:
$.ajaxSetup({
    cache: false
});

This is a smart thing, what it do is putting a timestamp in your request, so let's say you have this function:
Code:
$("#checkout").click(function(){
    var self = $(this);
    $.get(base_url+'ajax_fnc/is_logged_in/', function(data){
        alert(data);
        if(!data)
        {
            $("#login_btn").click();
            $('html, body').animate({scrollTop:0}, 'normal');
        }
        else
        {
            [removed] = self.attr('href');
        }
    });

    return false;
});

Your request becomes:

http://my_site.com/ajax_fnc/is_logged_in/?_=1274699621534

But codeigniter doesn't appears to like this type of URLs, I've already make this changes in config.php:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-&=';
$config['enable_query_strings'] = TRUE;

but I'm still getting 404 errors.

Any hint on how to prevent Internet Explorer to cache this type of ajax calls?
Or how to make CI to like this URL?

tks


Messages In This Thread
Jquery & Codeigniter ajax cache: false - by El Forum - 05-24-2010, 05:16 AM
Jquery & Codeigniter ajax cache: false - by El Forum - 05-24-2010, 08:48 AM
Jquery & Codeigniter ajax cache: false - by El Forum - 05-24-2010, 08:50 AM
Jquery & Codeigniter ajax cache: false - by El Forum - 05-24-2010, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB