Currently i have a big Page with a lot of macro content (my own macro).
It takes arround 5 seconds to open the page. (everytime i open the page my macro gets executed). And no, a cache macro can’t help here. The content of the macro only changes if the content has also been completely edited. Not after a period of time.Thereotically I could also write the result of the macro statically through a scheduler. However, the problem here is that the page content also contains the result of the macro.
Example of my macro:
{{includedoc id=“8989” /}}
Leads to an execution of an api access.
[[8989: Some example doc, wit a big description, which should not be included in the search >> http://...../docs?system=82367437238745437&doc=8989]]
Is there a way to save and display a static version of the page when saving the page? But without influencing the search? Or is there a way to give Solr a different search source text for this page?
You could configure the cache macro with a very high time period. Alternatively, if your macro is implemented in Java, you could also add a cache internally in the macro.
Another option, if you only use that macro on few pages, you could also configure the rendering cache for those pages. Again, you can simply configure a high cache duration.
@MichaelHamann thanks for the answer I still have questions regarding the two topics. I’m still a bit confused, especially when it comes to development.
Java Development
In general, however, I have two questions about development.
Macro Cache in java: I currently use my own solution (However, I’m not sure whether this applies at all. I am using a static variable here.), is there a simelar solution like “cached” from this wiki: WikiMacroTutorial but in java?
ExtendingMacro “Macro preparation”. I don’t quite understand that yet? Generally it is said here that it is only executed once and you can put things there? How exactly does it work now? Examples:
2.1. Page is saved → “prepare” → the content is saved → page is called → “execute” for each macro?
2.2. Page is called up → “prepare” but only once per page call → “execute” for each macro?
2.3 Page is called up → “prepare” for each macro → “execute” for each macro?
But here is also an example with: “this.contentParser.prepareContentWiki(macroBlock);” What exactly does it do then? With point 2.1, the content would be saved pre-rendered beforehand couldn’t I also use it to save my content? And if so, how? I could then query my api during prepare and save it in the macroblock. This should then be very performant even without a cache, because I then only have to render the information in execute without querying.
But with 2.2 it would make no sense as each macro has its own content. So I’ll rule that out.
2.3 Would be pointless, then I can just write everything in execute.
Page Rendering Cache
Is there also a way to configure this via the gui? It can happen that it changes from time to time, and I would hate to have to restart the server every time.
@MichaelHamann I think I can just wrap my macro in a cache macro? Right? or is there a java api directly from xwiki? The other question about prepare, is there any documentation?