1 / 7

How to enable Page Cache in CodeIgniter

Now with Lia infraservices u2013 Top Web App Development Company in Chennai, you can create these above-mentioned files and put them in their respective folder or you can download them from the link given.<br>

StephieJohn
Download Presentation

How to enable Page Cache in CodeIgniter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to enable Page Cache in CodeIgniter In this blog, we will see about how to enable Page Cache in CodeIgniter? by Lia Infraservices – The Leading Web App Development Company in Chennai. In general, caching is the process of storing copies of files in cache memory or temporary storage location like a hard disk, so that they can be accessed more quickly. Cache on the Internet serves a similar purpose. That is they temporarily store the page content, needed for users to make their journey across the web. Caching a page will improve the page load speed. If the page is cached, then it will be stored in its fully rendered state. Next time, when the server gets a request for the cached page, it will be directly sent to the requested browser.

  2. Cached files are stored in the application or cache folder. Caching can be enabled on a per-page basis. While enabling the cache, we need to set the time, until which it needs to remain in the cached folder and after that period, it will be deleted automatically. Procedure to Enable Page Cache in codeIgniter: Before moving into the steps to enable page cache in CodeIgniter, let us see what is CodeIgniter. What is CodeIgnitor? As you know JavaScript is the best Frontend development Programming language in Web Application Development In Chennai. The front end uses web languages such as CSS, HTML, and JavaScript. The programming languages used in the back end may include PHP, Java, Python, and Ruby. JavaScript is a dynamic language. It is mainly used for client-side scripting. Codeigniter is a JavaScript FrameWork, provides a library to help you with certain common functions that you may want to use with Javascript. Caching can be enabled by executing the following line in any of the controller’s methods. $this->output->cache(‘$n’); Where $n is the number of minutes you wish the page to remain cached between refreshes. How to create a page Cache?

  3. To create a page cache first you should create a folder name called cache in the application folder the image that I have given below for example And use this keyword call cache $this->output->cache(1); Sample code to create page cache agro: public function bob() { $data[‘sender’] = ‘alice’; $data[‘receiver’] = ‘bob’; $this->output->cache(1); $messages = $this->db->get(‘messages’)->result_array();

  4. foreach ($messages as $key => $message) { $messages[$key][‘text’] = $this->encryption->decrypt($message[‘text’]); } $data[‘messages’] = $messages; $this->load->view(‘chat’,$data); } Use this keyword You can see the cache file is created cache Apliar in the application folder the image given been below: How Deleting Caches affects CodeIgniter?

  5. If you no longer wish to cache a file you can remove the caching tag and it will no longer be refreshed when it expires. If you need to manually delete the cache, you can use the delete_cache() method: 1. Deletes cache for the currently requested URI $this->output->delete_cache(); 2. Deletes cache for /foo/bar $this->output->delete_cache(‘bob’); Sample code : public function sendMessage(){ $text = $this->input->post(‘message’); $text = $this->encryption->encrypt($text); $data[‘text’] = $text; $data[‘receiver’] = $this->input->post(‘receiver’); $data[‘sender’] = $this->input->post(‘sender’); $this->db->insert(‘messages’,$data); $this->output->delete_cache();

  6. redirect(base_url().’chat/’.$data[‘receiver’]); } Result: You can see the cache file have been deleted in the application folder the screenshot has been given below Screenshot for cache clear : Conclusion: Now with Lia infraservices – Top Web App Development Company in Chennai, you can create these above-mentioned files and put them in their respective folder or you can download them from the link given. Thanks for reading the complete post. Hope you have got the concept. You can share your views in the space provided below and get in touch with us – Contact Lia Infraservices.

More Related