Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching #9

Open
kenesa opened this issue May 10, 2017 · 2 comments
Open

Caching #9

kenesa opened this issue May 10, 2017 · 2 comments

Comments

@kenesa
Copy link
Collaborator

kenesa commented May 10, 2017

Hello @endel,

Question for you. I am looking at adding caching of the compiled templates and was wondering if you would like to have it added to the project. I know that folks at zordius/lightncandy have different views on 'compile-on-demand' but their recommended approuch does not work for all cases.

My idea would be to add it as a plugin to \Slim\Views\Lightncandy and would be used by the fetch() method.

What are your thoughts?

@endel
Copy link
Owner

endel commented May 11, 2017

Hey @kenesa, that's a really good idea.

It would be nice to have a new option when registering, like:

$app->register(new \Slim\Views\Lightncandy('path/to/templates', [
    'cache' => "path/for/cache"
]));

Is your idea to cache the result of the rendering, or to have a pre-compiled template that is faster to render new data on?

@kenesa
Copy link
Collaborator Author

kenesa commented May 11, 2017

@endel,

I was only going to cache the compliled templates to help eliminate the effort needed to compile the template. This makes it easy to determine when the cache is stale, basically when the templates modifed timestamp changes.

Caching the results after rendering is better left to an extension in Slim as it can capture the the results of the entire request/results process.

I was planning on making it a simple plugin so that if someone comes up with a different approuch it would be simple to plug it in. It would be more along these lines:

$cache = new \Slim\Views\TemplateCache('path/for/cache');
$view = new \Slim\Views\Lightncandy('path/to/templates');
$view->addCaching($cache);
$app->register($view);

Not quite as eloquent, but most of it would be handled in dependency injection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants