github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/partialCached.md (about)

     1  ---
     2  title: partialCached
     3  linktitle: partialCached
     4  description: Allows for caching of partials that do not need to be re-rendered on every invocation.
     5  godocref:
     6  date: 2017-02-01
     7  publishdate: 2017-02-01
     8  lastmod: 2017-02-01
     9  categories: [functions]
    10  menu:
    11    docs:
    12      parent: "functions"
    13  keywords: [performance]
    14  signature: ["partialCached LAYOUT INPUT [VARIANT...]"]
    15  workson: []
    16  hugoversion:
    17  relatedfuncs: []
    18  deprecated: false
    19  aliases: []
    20  ---
    21  
    22  The `partialCached` template function can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation. Here is the simplest usage:
    23  
    24  ```
    25  {{ partialCached "footer.html" . }}
    26  ```
    27  
    28  You can also pass additional parameters to `partialCached` to create *variants* of the cached partial. For example, if you have a complex partial that should be identical when rendered for pages within the same section, you could use a variant based upon section so that the partial is only rendered once per section:
    29  
    30  {{< code file="partial-cached-example.html" >}}
    31  {{ partialCached "footer.html" . .Section }}
    32  {{< /code >}}
    33  
    34  If you need to pass additional parameters to create unique variants, you can pass as many variant parameters as you need:
    35  
    36  ```
    37  {{ partialCached "footer.html" . .Params.country .Params.province }}
    38  ```
    39  
    40  Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key.