Skip to content

Output Cache Views (Query) #543

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

Closed
feanz opened this issue May 16, 2018 · 9 comments
Closed

Output Cache Views (Query) #543

feanz opened this issue May 16, 2018 · 9 comments
Milestone

Comments

@feanz
Copy link

feanz commented May 16, 2018

This is more of a query than an issue. Sorry if this is not the best place to ask. If there is a better place to raise this feel free to let me know and close the issue.

I'm using ReactJs.net on a large Sitecore Site (.net Enterprise CMS). We have created a really nice model where we integrate React frontend components to Sitecore CMS components. For those who have not used Sitecore it uses Asp.net MVC under the covers to create markup for custom components. This is where we plumb in ReactJs.net.

My question is, is it possible to support the output caching of these views with React? The current issue I am seeing is that the server side rendered markup is there and the content is visible but because the @Html.React call has never been made then that component is not in the Hydrate call. Then react component never initialises. This is fine for components that have not interactivity but for anything else it breaks. Does anyone have a solution for this?

@dustinsoftware
Copy link
Member

Hmm. Have you tried using Html.ReactWithInit so that the component markup and script tag is rendered in one method call? That sounds like it will avoid the caching problem you're having.

@feanz
Copy link
Author

feanz commented May 17, 2018

Thanks @dustinsoftware that was super helpful I did not know this was a feature. I may have to extend it to get the hydrate to happen on page load to hit some other bench marks but this will fix my output cache issue

@feanz feanz closed this as completed May 17, 2018
@gregsmith-ie
Copy link

@feanz did you end up developing a solution for hydrating on page load?

@feanz
Copy link
Author

feanz commented Jun 25, 2018

Yeah i used the recommended @Html.ReactWithInit method. This does require you to include react and your components scripts before the first component is rendered. This is not great for page paint speed. I created a custom React method that add the hydrate call to an array functions in js. Then I add a call at the end of the body that calls all these functions, so that we can move the react script load to the end of the body.

@aventic
Copy link

aventic commented Mar 26, 2019

@feanz can you share an example on how you did this? Struggling with the same issues. Thanks :-)

@dustinsoftware
Copy link
Member

@aventic are you observing slow rendering problems if you include your script tags first and use ReactWithInit? I think this is a scenario we should have a better story for, so gathering data for where the pain points are.

@aventic
Copy link

aventic commented Apr 12, 2019

@dustinsoftware Sorry for the late answer. Well reason is I dont want to load my script at the very top of my page. I want to load it at the bottom, so all the dom elements are ready and loaded. Sitecore is using renderings, those renderings are getting cached, therefor I did as @feanz. I created a react functions array on the Html helper method, which I then run just after my bundle is initialized in the bottom of the page.

@dustinsoftware
Copy link
Member

Re-opening this issue so we can make the caching scenario better in 5.0

@dustinsoftware dustinsoftware added this to the 5.0 milestone Apr 29, 2019
dustinsoftware added a commit that referenced this issue Jun 17, 2019
This allows Output Caching to be used, in #543

Still needs tests and documentation updates
dustinsoftware added a commit that referenced this issue Jul 5, 2019
This allows Output Caching to be used, in #543

Still needs tests and documentation updates
dustinsoftware added a commit that referenced this issue Jul 5, 2019
This allows Output Caching to be used, in #543

Still needs tests and documentation updates
@dustinsoftware
Copy link
Member

Resolved by #858

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

No branches or pull requests

4 participants