Greetings,
I'm writing a CI web application which implements the standard file caching functionality as such:
$this->output->cache(n);
I'm using a combination of segments and query string parameters, and appear to be experiencing an issue as a result. What I'm seeing in my use cases and in the Output class code is that the caching is solely segment based. As such, http://www.example.com/segment/?q=foo and http://www.example.com/segment/?q=bar are treated as identical requests.
Does anyone have any insight or recommendations regarding how the url_helper, Output class, or CI base class can be edited such that the above example treats example.com/segment/?q=foo and example.com/segment/?q=bar as separate, unique requests and stores the responses in separate files individually?
Here's some code to override Codeigniter's Output class which seems to work for me.
Create the file application/core/MY_Output.php, copy in the _write_cache() and _display_cache() functions from Output.php and update it like this:
You should cache if the value of _GET is empty
this can fix codeigniter cache with querystring codeigniter cache with querystring
it is thai language page but you can just copy that code and put it in application/core/MY_Output.php :)
Into config/config.php
You should enable cache_query_string like this
take all query parameters into account. Please be aware that this may result in numerous cache files generated for the same page over and over again.