Skip to content

Add caching option for partials #6

Open
@connorshea

Description

@connorshea

Right now I have a header partial added to every page in our documentation. It's using dynamic URLs rather than static to ensure that the data it pulls from is updated when we add new versions.

Simplified version of the header partial:

<div class="header">
  <a href="/">
    <%= logo %>
    <p>GitLab Documentation</p>
  </a>
  <div>
    <ul>
      <%= search %>
      <% @config[:products].each do |name, product| %>
        <li>
          <%= link_to_stable %>
          <ul>
            <% product[:versions].each do |version| %>
              <%= link_to_version %>
            <% end %>
          </ul>
        </li>
      <% end %>
    </ul>
  </div>
</div>

Essentially, every version's README needs to be found for the dropdowns to be generated (link_to_version is actually <a href="<%= @items["/#{product[:slug]}/#{version_name}/#{product[:index_file]}"].path %>">), which is expensive to compute on every single page. The content is entirely static and could be cached and reused across every page on the site which would make the site a lot faster.

Adding caching to the partial, a la Rails' partial caching would be a huge benefit for us.

Right now in layouts/default.html we have:

<%= render '/header.*' %>

I would imagine caching would just look like:

<%= render '/header.*', cache: true %>

It could also be called static? Perhaps to simplify the code, cached partials couldn't use yield?

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions