Disable Output Cache for Logged in Users |
[eluser]rickyracoon[/eluser]
Is there any way to disable output caching for logged in users? I saw a technique described in this thread which is in line with what I need to accomplish, but the posted solution seems like it requires a lot of needless processing that may hinder some of the performance benefit of caching: http://ellislab.com/forums/viewthread/151752/#735929 Any thoughts/solutions/hacks would be appreciated.
[eluser]rickyracoon[/eluser]
Only way I can think of is to use the native session to keep track of auth state and edit Codeigniter.php to look like this: Code: session_start(); Then in MY_Controller.php I would do this: Code: session_start(); Does anyone see any potential problems or drawback with doing it this way (other than the obvious...hacking core, etc...)? I'm using ion_auth library of course for authentication.
[eluser]rickyracoon[/eluser]
Ok, so I did some testing and I think I have it working now, but it required a lot of hacking. Here are the final code modifications I made. /system/application/libraries/MY_Controller.php (add this snippet to constructor): Code: if ( ! isset( $_SESSION ) ) /system/libraries/Output.php (added code below to beginning of functions): Code: function _write_cache( $output ) /system/codeigniter/Codeigniter.php (modified section below): Code: /* And that did the trick. Now, caching works as expected when user is not logged in. When they log in, caching is essentially disabled or skipped. Hope this helps someone who needs something similar. I know this isn't the cleanest approach would love some feedback. |
Welcome Guest, Not a member yet? Register Sign In |