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

Handle view caching #6

Closed
wants to merge 1 commit into from
Closed

Handle view caching #6

wants to merge 1 commit into from

Conversation

@nightsurge
Copy link

@nightsurge nightsurge commented Jun 8, 2017

Potentially take advantage of rails fragment/view caching.

Your view partial would need to use some established cache key method. I just used "views/#{path}_cached" as a quick example.

In your view:
<% cache "#{path}_cached" do %> '<div>Some code</div>' <% end %>

Would create a "views/some_action/_cached" key the first time your render_async is used. Can also pass in an expires_in: 10.minutes option.

Potentially take advantage of rails fragment/view caching.

Your view partial would need to use some established cache key method. I just used "views/#{path}_cached" as a quick example.

In your view:
`<% cache "#{path}_cached" do %>
   '<div>Some code</div>'
<% end %>`
@@ -4,6 +4,9 @@ module RenderAsync
module ViewHelper

def render_async(path)
cached_view = Rails.cache.read("views/#{path}_cached")

What if we are also passing different parameters? Shouldn't we cache based on not just path but params as well?

Copy link
Collaborator

@nikolalsvk nikolalsvk Jul 1, 2017

I think params would be picked up in the path variable.

Great question by the way, there should be a test for this so we are 100% sure :)

@basicBrogrammer
Copy link

@basicBrogrammer basicBrogrammer commented Jun 30, 2017

Just found the gem. Awesome idea! Curious how well does it play with Turbolinks 5? And Turbolinks 5 page preview?

@basicBrogrammer
Copy link

@basicBrogrammer basicBrogrammer commented Jun 30, 2017

Is it possible to test this scenario?

@nightsurge nightsurge closed this Aug 31, 2017
@nikolalsvk
Copy link
Collaborator

@nikolalsvk nikolalsvk commented Aug 31, 2017

Continued in another PR #14

@basicBrogrammer do you maybe have an idea why it wouldn't play well with Turbolinks 5? :)

@basicBrogrammer
Copy link

@basicBrogrammer basicBrogrammer commented Sep 1, 2017

@nikolalsvk I made that comment when I first found this gem. After looking through the code, I would say it should work find with turbolinks bc it is in the body and turbolinks only caches the head. 👍

@nikolalsvk
Copy link
Collaborator

@nikolalsvk nikolalsvk commented Sep 1, 2017

@basicBrogrammer Awesome 👍

I'm working on releasing render_async_cache, a way to cache your AJAX calls so you can give it a spin when I finish it.

@juanfurattini
Copy link

@juanfurattini juanfurattini commented Aug 4, 2018

@nikolalsvk is the render_async_cache finished?

@nikolalsvk
Copy link
Collaborator

@nikolalsvk nikolalsvk commented Aug 6, 2018

@juanfurattini yes it is! There's a section in the README about caching https://github.com/renderedtext/render_async#caching

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

Successfully merging this pull request may close these issues.

None yet

5 participants