Home.html get created 401 times

I have quite some posts in my weblog (more than 2000) and was wondering, where I could make some speed improvements for the development server. It typically runs at least 30 seconds pro change. Moving posts away from from development and keeping 20 posts might help. But: When running with template metrics this is the table I get back:

Template Metrics:

      cache     cumulative       average       maximum         
  potential       duration      duration      duration  count  template
      -----     ----------      --------      --------  -----  --------
          0 26.156428927s   65.228002ms   105.10227ms    401  _default/home.html
         41   21.1554492s   52.756731ms   90.709443ms    401  partials/pagination/posts.html
          0  558.426923ms  558.426923ms  558.426923ms      1  _default/list.algolia.json
         93   86.389561ms     215.435µs     376.076µs    401  partials/head/open_graph.html
        100   78.326376ms     195.327µs     437.214µs    401  partials/header/navigation.html
         84   69.252831ms       172.7µs      562.33µs    401  partials/head/metadata.html
        100   67.956664ms     169.467µs    2.446795ms    401  partials/head/twitter.html
        100   38.514878ms      96.047µs     398.436µs    401  partials/head/pagemeta.html

Do I misunderstand something or is my _default/home.html built 401 times? I would expect it to be counted once only, for the homepage? I also miss the post _default/single.html being listed. I am relatively sure my template lookup order is messed up.

My repo is here: https://github.com/davidsneighbour/samui-samui.de

When I visit your site the first thing I see is the pagination key:


401 is pretty specific, so maybe that has to do with it. Your repo is hefty for me to clone and troubleshoot at the moment, but maybe you can comment out the paginator and check the metrics.


Yes, I think I will end up having a theme branch with about 20 entries only. The 401 is indeed the amount of pages, but should the homepage be done 401 times? I feel like the homepage template is used as list template.

I’ll add a comment here when I have the dev branch ready.

Well, yes. Your pagination is unique to each page (active page not being a link, numbers of pages links shown etc…) so this is not a partial you can cache.

I would increase the numbers of posts per page to decrease the number of pages in the paginator.

The pagination is in it’s own partial. The homepage gets rendered 401 times too, only including that partial. Do I understand that if a partial is rendered x times the template using that partial is rendered x times too? That would explain much.

Yes I think so.

A partial is just a way to include some file’s markup in a template. If that included markup changes for each pages and cannot be cached, I believe the whole page needs to be build again. But that’s just me guessing.

So it’s probably better to keep those partials in the list file itself. I’ll be testing around if that makes rendering faster. I also think maybe just having prev/next or newer/older links might be easier to implement. This whole numbers thing is just vanity :smiley:

1 Like