Skip to content

alternative caching strategy #32

@koenhandekyn

Description

@koenhandekyn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions