Disable browser cache easily with codeigniter – onlinecode
In this post we will give you information about Disable browser cache easily with codeigniter – onlinecode. Hear we will give you detail about Disable browser cache easily with codeigniter – onlinecodeAnd how to use it also give you demo for it if it is necessary.
In this tutorial, we are going to how to disable browser cache easily with Codeigniter. normally, When the user logout that time destroy the session but when we click to ‘Go Back’ button on own browser we can see the cached dashboard page. in that time we have faced that type of issue.
How to disable browser cache easily in Codeigniter, How to avoid browser cache, Disable cache in Codeigniter, Codeigniter cache
Config setting
We will configure prefix in config.php file on “application/config” directory. if you want to keep custom prefix different name then you can. This item allows you to set the filename/classname prefix when extending.
$config['subclass_prefix'] = 'MY_';
So, we will create MY_Output.php file on “application/core” directory. after then paste the below code in this file.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class MY_Output extends CI_Output { function nocache() { $this->output->set_header("HTTP/1.0 200 OK"); $this->output->set_header("HTTP/1.1 200 OK"); $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); $this->output->set_header("Cache-Control: post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); } } ?>
Now, we will paste below code in the constructor function for first-time call the controller. because when call that method then it’s every time disable browser cache.
$this->output->nocache();
Hope this code and post will helped you for implement Disable browser cache easily with codeigniter – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs