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

alternative caching strategy #32

Open
koenhandekyn opened this issue Oct 24, 2017 · 1 comment
Open

alternative caching strategy #32

koenhandekyn opened this issue Oct 24, 2017 · 1 comment
Labels

Comments

@koenhandekyn
Copy link

just a suggestion that might be added to the documentation.

i'm using render async with this pattern: i'm rendering the existing partials by adding paths and methods that just render the existing partials, while making use of the existing request caching mechanisms. the key advantage is that it's not taking cache memory on the server but it's using the client side (or in between) HTTP caches. for full correctness, fragment caching is complimentary in the general case, but in general the HTTP caching should not be forgotten and can bring extra 'relief' for the server.

  def _details
    authorize @node, :show?
    if (stale?(@node)) # makes the browser cache subsequent requests
      readonly = (current_user == nil) || (current_user.can_write? == false)
      render partial: 'details', locals: {node: @node, node_structure: @node_structure, readonly: readonly}
    end
  end
@nikolalsvk
Copy link
Collaborator

Great suggestion @koenhandekyn, thanks for sharing this.

If you're up for it, you can make a PR that adds this recipe to documentation :)

Let me know in the comment or by creating a PR 🍻

@nikolalsvk nikolalsvk added the docs label Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants