output->cache() Not Caching Correctly due to incorrect uri in md5($uri) |
[eluser]haydenp[/eluser]
Hi I came across this whilst debuggin my page caching. I scoured the forums as I was initially having the common "blank page" caching problem. This I resolved through the following thread Displaying_Multiple_Views Once that was resolved my pages were caching in full as expected but I was not convinced by the performance. After inspecting the logs I noticed that the pages were being written to cache on every page load. ie. "Cache file written ..." every time I refreshed the page. I added a little debugging code to the _display_cache() and _write_cache() methods in "libraries/Output.php" and the following is what it echos to the screen ... Code: _display_cache ... CFG->item(index_page) = index.php In short: _write_cache() _write_cache() uses config->item(index_page) = index.php/ ... in the md5($uri) _display_cache() _display_cache() uses CFG->item(index_page) = index.php ... in the md5($uri) NOTE: The missing "/" in _display_cache() So effectively, although _write_cache() is caching the page correctly, _display_cache() is looking for a different page cos the two md5($uri)'s are different co's on has the "/" at the end, the other does not. Note: I am using CI Version 1.7.1 and config setting as follows: $config['index_page'] = "index.php"; $config['url_suffix'] = ""; Cheers, Hayden
[eluser]haydenp[/eluser]
Me again ... I find it strange that no one else has come across this bug? Recently on another site using a fresh CI install (same version as above) I came across this exact same issue ... to add to my above post I've added the debugging code and results: _write_cache Inside the above method I added: Code: echo '<p>_write_cache ... uri = ' . $uri; The result: _write_cache ... uri = http://10.9.9.5/mysite/index.php//contro.../var2/var3 _write_cache ... base_url = http://10.9.9.5/mysite/ _write_cache ... index_page = index.php/ _write_cache ... uri_string = /controllername/method/var1/var2/var3 _display_cache Code: echo '<p>_display_cache ... uri = ' . $uri; The result: _display_cache ... uri = http://10.9.9.5/mysite/index.php/control.../var2/var3 _display_cache ... base_url = http://10.9.9.5/mysite/ _display_cache ... index_page = index.php _display_cache ... uri_string = /controllername/method/var1/var2/var3 Conclusion In _write_cache(), $CI->config->item('index_page') returns the config index page and incorrectly APPENDS a '/' to the end. To fix I modified _write_cache()... From: Code: $uri = $CI->config->item('base_url'). To: Code: $uri = $CI->config->item('base_url'). Anyone? |
Welcome Guest, Not a member yet? Register Sign In |