Welcome Guest, Not a member yet? Register   Sign In
Caching or generating?
#1

[eluser]xwero[/eluser]
If people want to speed up their site they turn to cache solutions but why not serve generated static files to start with?

Let's take a blog for example. A blog page has two major parts, the blog post and the comments. Normally to build the frontend page you do something like
Code:
$data['post'] = $this->load->view('blog/post',$this->blog_model->post($id),true);
$data['comments'] = $this->load->view('blog/comments',$this->blog_model->comments($id),true);

$this->load->view('blog/page',$data);
With generated files you can do this
Code:
$data['post'] = include("blog/post_$id");
$data['comments'] = include("blog/comments_$id");

$this->load->view('blog/page',$data);
I left out all the security checks on purpose.

Why have a caching library that saves a partial or a page as a file where you have to use the library as an interface to manipulate the cache files if you can work it in your app and have full control over the files?
Cache libraries often put a lifetime on files but most of them are not hooked into the manipulating actions which can cause differences between the updated content and the frontend content.

Most pages on a site are almost static so why would you have to create them each time a visitor wants to see them? Why not use php just to glue pageparts together?

Of course these pages take up disk space but the time of 50mb or less hosting accounts are over and most of the time the user uploads will exceed the generated files space by a lot.

All comments are welcome


Messages In This Thread
Caching or generating? - by El Forum - 04-20-2009, 03:57 AM
Caching or generating? - by El Forum - 04-20-2009, 10:16 AM
Caching or generating? - by El Forum - 04-20-2009, 11:54 AM
Caching or generating? - by El Forum - 04-20-2009, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB