Partial Page Caching Extension, some questions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Partial Page Caching Extension, some questions

Antibrumm
Hi

I'm trying to implement a Partial Page Cache dialect extension for Thymeleaf and while I already have a running version there is still some mayor improvement to be done. So i could use some hints on how to proceed from here:

Two questions:
Currently I use the fragment cache to cache the partial page: arguments.getTemplateEngine().getCacheManager().getFragmentCache().

Is there a timeout of cache entries in these caches or should I add a specific cache which handled entry timeouts explicitly?
I think the Fragment cache is permanent and only evicts on cache size right?


Currently I cache the processed element tree as a DOM structure and call setProcessable(false) once they are found and replaced by the CacheProcessor. Thats obviously not perfect from the performance point of view.

Is there a way to get the rendered output of a DOM structure on the server side?
I have not found an entry point in the TemplateEngine and I don't think there is something i could call on the Node right? Then i would put the resulting String into the cache and use the Marco class where I could set the content so that this would just be written straight to the response.



For those interested, the dialect is on GitHub:

Think about menu which should be dynamic per user role, etc.

Currently, even in this not optimized version, I'm able to get +-50% of response time for a cached list with 1000 elements.


https://github.com/Antibrumm/thymeleaf-extras-cache-dialect

Thanks
Antibrumm
Reply | Threaded
Open this post in threaded view
|

Re: Partial Page Caching Extension, some questions

Zemi
Administrator
 > Is there a way to get the rendered output of a DOM structure on the server side?

We have previously used a trick to achieve this.

The "magic" is done by this class
    http://sourceforge.net/p/html5valdialect/code/HEAD/tree/trunk/core/src/main/java/net/sourceforge/html5val/DelayedProcessorInvoker.java

You can see an example of its use in
   http://sourceforge.net/p/html5valdialect/code/HEAD/tree/trunk/core/src/main/java/net/sourceforge/html5val/ValidateCommand.java

Regards,
   Zemi

Reply | Threaded
Open this post in threaded view
|

Re: Partial Page Caching Extension, some questions

Antibrumm
Thanks Zemi

I use the same approach, just that it is part of the processor directly.

This helps in getting the final DOM but they are still nodes at this time. What i would like to get is the final output of these elements as a string. This string i would cache and place it with the help of the Macro object into the DOM.

I just took a quick look at your validation dialect and if i'm right you are validating not the resulting output but rather each final element and its attribute. Is that correct?
Reply | Threaded
Open this post in threaded view
|

Re: Partial Page Caching Extension, some questions

Antibrumm
Okay. I got it. Found a way to reach the templateWriter. Now i cache the resulting output string. Everything was available through the Arguments. Nice engine, once again :)

Now just the cache eviction strategy is missing.
Reply | Threaded
Open this post in threaded view
|

Re: Partial Page Caching Extension, some questions

Zemi
Administrator
In reply to this post by Antibrumm
 > if i'm right you are validating not the resulting output but rather each final element and its attribute. Is that correct?

Yes, we do not process the String output, but the DOM output.

i'm glad you resolved it.

Regards,
   Zemi