Skip to content

{{ nocache }} file disk storage optimization #11178

Open
@dadaxr

Description

@dadaxr

Bug description

I may be wrong but, I figured that using nocache tag, even with the select parameter set to restrict which variable to hydrate... the whole template context seems to be stored in the disk, which impacts performance and available disk space...

Would it be possible to also take the select parameter into account, so we can avoid caching unnecessary data.
(In my project, the static-url-cache folder can end up containing more than 100 go of files ... )

Kind of related to #9124 and #10281

How to reproduce

For instance, if you have a template like this :

{{ allProducts = {collection:products} }}
{{ firstProduct =  allProducts[0] }}

{{ nocache select="firstProduct" }}
  {{# do something which require the first product and need to not be cached like checking it's stock for instance #}}
  {{ app:checkProductStock :product="firstProduct" }} 
{{ /nocache }}

{{ allProducts }}
  {{# do something with cached products #}}
{{ /allProducts }}

In that case, a file in the statamic/static-url-cache will be created for the {{ nocache }} region, and will contain both "allProducts" and "firstProduct" serialized, even if "firstProduct" is needed ... It seems the "select" parameter optimization is only used when re-hydrateding the context from cache, but not before storing the context...

Logs

No response

Environment

Environment
Laravel Version: 10.48.13
PHP Version: 8.2.23
Composer Version: 1.10.27
Environment: prod
Debug Mode: ENABLED
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / daily
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Disabled
Static Caching: half
Version: 5.38.0 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

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