How to cache a modified view? |
[eluser]gminuses[/eluser]
I try to compress my view and then cache it like this: Code: class MyController extends Controller { Quote:caching will only work if you are generating display for your controller with a view. So how can I trigger a caching after processing the output?
[eluser]Clooner[/eluser]
I use a custom caching helper: http://ellislab.com/forums/viewthread/127155/
[eluser]louis w[/eluser]
Could you just pass your compressed html into another view and output it through that? Then I think it would be cached? Code: class MyController extends Controller { Inside views/output.php just <?php echo $html; ?> It's kind of a hackish way to accomplish this but would allow you to use the native caching library (i think).
[eluser]gminuses[/eluser]
To clooner: It seems to be a little overkill, but If I'm running out methods, I'll try that. Thanks. To louis w: This might not be a solution. If I have multiple html files to be compressed, I'll have to create this kind of view for every single of them, which is tedious and unmaintainable. Anyway, thanks for the reply.
[eluser]louis w[/eluser]
Couldn't you just use the same output view for all the pages? All it's doing is echoing what you feed it.
[eluser]louis w[/eluser]
Have you also tried instead of your original echo? I don't use the CI cache mechanism but it looks like this might work because it get's written with the output->_display method. $this->output->set_output($html);
[eluser]gminuses[/eluser]
[quote author="louis w" date="1255550364"]Couldn't you just use the same output view for all the pages? All it's doing is echoing what you feed it.[/quote] I thought if I use same view for all pages, once it got cached, the following pages won't be displayed, because the view is already cached. Now I figure I might be wrong? [quote author="louis w" date="1255550505"]Have you also tried instead of your original echo? I don't use the CI cache mechanism but it looks like this might work because it get's written with the output->_display method. $this->output->set_output($html);[/quote] This works like a charm, Thanks! |
Welcome Guest, Not a member yet? Register Sign In |