Forums / Developer / template compile cache refresh interval

template compile cache refresh interval

Author Message

Marko Žmak

Friday 03 June 2011 7:00:23 am

Is there a way to setup the refresh interval for the compiled eZP templates?

So that for example, if the template is older than 30 minutes, it's recompiled again.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Brandon Chambers

Friday 03 June 2011 10:18:23 am

It seems you're asking for the entire template to be re-compiled..? Have you considered the {cache-block} way?

http://share.ez.no/learn/ez-publish/ez-publish-performance-optimization-part-3-of-3-practical-cache-and-template-solutions/%28page%29/9

If you need to re-compile the templates entirely I suggest using a cronjob to clear template cache every 30 minutes with the ezcache script from the CLI:

 php bin/php/ezcache.php --clear-tag=template

Then use the template compile script.

 php bin/php/eztc.php

I did a quick search in eztc.php and I don't think it triggers caches to be cleared but I could be wrong. So this should cover everything, except check eztc.php for the correct options you want.

Here's the cache doc page:

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Scripts/Generic/ezcache.php

Unfortunately I couldn't find any documentation on the eztc script except for an old page cached by Google:

http://webcache.googleusercontent.com/search?q=cache:ZDsZqD4VjtAJ:https://85.19.74.108/ezpublish/documentation/development/scripting/supplied_scripts/template_compiler+ez+publish+template+compile+script&cd=1&hl=en&ct=clnk&gl=us&source=www.google.com

 

I hope this helps!

Brandon Chambers
[email protected]
blog: http://blog.divdesigns.com
Granite Horizon / http://granitehorizon.com

Marko Žmak

Friday 03 June 2011 2:13:58 pm

Hi Brandon, I'm already aware of all the things you mention. But I would like some of the eZP developers to give a 100% sure answer about refreshing compiled templates.

More precisely:

  • when the templates are compiled are they ever refreshed without clearing the cache manually? Can an eZP site "live" forever only on compiled templates without having the eZP templates in the design folder?
  • is there a mechanism to set a refresh intreval for this?

So anyone from eZP dev crew whishes to comment on this one?

 

P.S. As for the old doc you mentioned it can be found here:

It's a pitty we don't have this in the new docs, but I hope this wll change.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Brandon Chambers

Friday 03 June 2011 2:51:12 pm

Ahh I see.. Would be nice for an official answer, unfortunately I cannot provide that. Maybe Lukasz, Paul Borgermans or Nicolas could fill us in?

Although, now most of everyone is alseep in Europe. We shall see..

Brandon Chambers
[email protected]
blog: http://blog.divdesigns.com
Granite Horizon / http://granitehorizon.com

Gaetano Giunta

Saturday 04 June 2011 11:38:32 am

@Marko To get precise answers, your gotta give precise questions ;-)

Are you talking about compiled-tempates cache, view cache, cache-block cache or all of them together?

As far as I know, once your compiled-templates cache is fully warmed up, you could run the whole website without the original templates. But I've never seen it done in real life so far.

View-cache and template-block cache are different beasts, as they will expire based on unpredictable conditions.

To regenerate caches bqsed on time intervals, set up a cronjob that

- runs ezcache.php to clear the cache you want thim to

- runs eztc.php to warm template cache, and/or wget to warm content cache + tpl block cache

This I have seen done in a few real life sites. Esp. clearing caches by hand, when there is a lot of content and different users roles / view parameters, can be used to prevent the size of created cache files to grow too much.

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Saturday 04 June 2011 12:04:11 pm

As the title of the post (and the text itself) says I'm asking about compiled templates cache :)

The main thing I'm interested in here is runing the site without original templates, so only on PHP compiled templates. And having the posbility to refresh them periodically or manually.

If your statement about the compiled templates is true, there's another question...

Would it be possible to generate the compiled templates on another machine, on an exact copy of the eZP installation, and then just copy them to the live site installation (which doesn't have the eZP templates)?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Gaetano Giunta

Saturday 04 June 2011 2:57:04 pm

I've been digging into the code (and testing too), and it seems this is currently not supported, unfortunately.

The culprit seems to be eZTemplateFileResource::handleResourceData(), which checks for existence of original template file before checking for its cached version.

Makes for a good feature request though...

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Saturday 04 June 2011 3:24:06 pm

ps: http://issues.ez.no/18371

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Sunday 05 June 2011 3:27:04 am

I also tested it and yes, when I remove the folder with original templates, the site is not working.

Regarding your submited issue:

  • why do we need the INI setting for it? I mean if we have a compiled version of the template why do we ever need to touch the original?
  • it says it is incporporated by issue 016413. So what does it mean, is it implemented in some community version and which one? How exactly is it implemented and how can we verify it?

P.S. Please correct the link to the issue.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Marko Žmak

Sunday 05 June 2011 3:29:03 am

"

Would it be possible to generate the compiled templates on another machine, on an exact copy of the eZP installation, and then just copy them to the live site installation (which doesn't have the eZP templates)?

"

P.S. Any toughts about this one?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Gaetano Giunta

Sunday 05 June 2011 2:01:45 pm

A new ini setting is just a way to add new features while striving for maximum backwards compatibility - not testing if original template is still there is mostly safe, but what I propose is not to check if the original template is newer than the cached version, and this might have an impact.

About marking it as part of another issue: it's just about linking related issues together - for every possible topic there are at least a dozen issues already in the tracker, and before submitting code to close them it is good to have a broader overview. It also helps in closing old issues that otherwise linger forever...

Last but not least: if the original templates are present on the target server, you should be able to copy the compiled version after having produced it somewhere else. You'll just need to make sure that the timestamp of the compiled version is later than the one of the original template.

One more detail: for every 'page' shown by eZ, I think the check for presence of the original template applies in general to only 2 templates. All templates included via 'include' template operator calls are not checked for presence of the original or its timestamp...

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Monday 06 June 2011 5:37:36 am

"

About marking it as part of another issue: it's just about linking related issues together - for every possible topic there are at least a dozen issues already in the tracker, and before submitting code to close them it is good to have a broader overview. It also helps in closing old issues that otherwise linger forever...

"

What I was really trying to ask is if this other issue was already solved (and thus solved this one too) or will it be solved soon?

The fix version the second issue is "Customer request", what does that mean?

"

One more detail: for every 'page' shown by eZ, I think the check for presence of the original template applies in general to only 2 templates. All templates included via 'include' template operator calls are not checked for presence of the original or its timestamp...

"

I believe that depending on caching and other settings there could be more than 2 checks. As I commented in the issue, we have template fallback system, *_view_gui, OE tags, embed objects...

It would be nice to see a real mesurement of how much stat calls are really made when loading an eZP page...

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth