Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

How to prevent view cache in one controller method?

edited November 2016 in Share
I have a view that uses some frequently updated data from a remote source, in fact the updates could be arbitrary. The view is being cached though, & I'd like to turn off cacheing (but keep the assets cached). Is this possible?

Comments

  • edited 5:30PM
    Is this a page from the CMS? If so, you can check the "no" radio for the Cache option in the CMS.
  • edited 5:30PM
    No it's a regular controller view. I tried using the headers to prevent cacheing, and the asset library continues to optimise and concatenate the scripts & css, which is what I wanted, and it all seems to work. I just wondered if there was a "Fuel way" of achieving this!

    Does Fuel augment Codeigniter's cache behaviour in these situations?
  • edited 5:30PM
    FUEL uses it's own caching library separate from CodeIgniters:
    http://docs.getfuelcms.com/libraries/fuel_cache
  • edited November 2016
    Yes - I use this a lot now with all sorts of resources - queries especially like so:
    // try cache $cache_id = 'mycache'; if(!$data = $this->fuel->cache->get($cache_id)) { $this->load->model('data_model'); $data = $this->data_model->find_all_array(NULL, 'last_modified DESC'); $this->fuel->cache->save($cache_id, $data, NULL, 3600); } // ....use the $data as intended

    But there is no "exclude from cache" in its methods? Ultimately I used this:
    $this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Sign In or Register to comment.