{"id":27707688,"url":"https://github.com/swiss-devjoy/blade-staticcache-directive","last_synced_at":"2026-03-05T09:33:15.071Z","repository":{"id":288290831,"uuid":"966785861","full_name":"swiss-devjoy/blade-staticcache-directive","owner":"swiss-devjoy","description":"Put chunks of your Blade template into immutable static cache files","archived":false,"fork":false,"pushed_at":"2025-06-07T06:40:51.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T17:02:26.634Z","etag":null,"topics":["blade","laravel","performance","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swiss-devjoy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"swiss-devjoy"}},"created_at":"2025-04-15T13:01:34.000Z","updated_at":"2025-06-07T06:40:55.000Z","dependencies_parsed_at":"2025-04-16T23:14:53.172Z","dependency_job_id":"362011db-0437-4070-9528-dcdaec322e48","html_url":"https://github.com/swiss-devjoy/blade-staticcache-directive","commit_stats":null,"previous_names":["swiss-devjoy/blade-staticcache-directive"],"tags_count":2,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/swiss-devjoy/blade-staticcache-directive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Fblade-staticcache-directive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Fblade-staticcache-directive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Fblade-staticcache-directive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Fblade-staticcache-directive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiss-devjoy","download_url":"https://codeload.github.com/swiss-devjoy/blade-staticcache-directive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Fblade-staticcache-directive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blade","laravel","performance","php"],"created_at":"2025-04-26T07:55:42.802Z","updated_at":"2026-03-05T09:33:15.052Z","avatar_url":"https://github.com/swiss-devjoy.png","language":"PHP","funding_links":["https://github.com/sponsors/swiss-devjoy"],"categories":[],"sub_categories":[],"readme":"# Put chunks of your Blade template into immutable static cache files\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/swiss-devjoy/blade-staticcache-directive.svg?style=flat-square)](https://packagist.org/packages/swiss-devjoy/blade-staticcache-directive)\n[![Total Downloads](https://img.shields.io/packagist/dt/swiss-devjoy/blade-staticcache-directive.svg?style=flat-square)](https://packagist.org/packages/swiss-devjoy/blade-staticcache-directive)\n\nIncrease performance by putting chunks of your Blade template into immutable static cache files. This package provides a directive for Blade templates that allows you to easily create static cache files for specific sections of your views. With OPCache enabled, this can significantly reduce the time it takes to render your views, especially for large and complex templates.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require swiss-devjoy/blade-staticcache-directive\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"blade-staticcache-directive-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    'enabled' =\u003e env('BLADE_STATICCACHE_DIRECTIVE_ENABLED', true),\n\n    // Cache profile which generates the unique key for the cache entry\n    'cache_profile' =\u003e \\SwissDevjoy\\BladeStaticcacheDirective\\CacheProfile::class,\n];\n```\n\n## Usage\n\n```blade\nThis is a blade template.\n\n@staticcache('my-cache-key')\n    {{ $this-\u003eaVeryExpensiveMethod() }}\n@endstaticcache\n```\n\nTo clear the cache you can run the following command:\n\n```bash\n$ php artisan blade-staticcache:clear\n```\n\nTo include some additional stats in your response about cached/uncached blade chunks, you can use the provided middleware:\n\n**For laravel 11.x and newer:**\n\nAdd the middleware definition to the bootstrap app.\n\n```php\n// bootstrap/app.php\n\n\n-\u003ewithMiddleware(function (Middleware $middleware) {\n    ...\n    $middleware-\u003eweb(append: [\n        ...\n        \\SwissDevjoy\\BladeStaticcacheDirective\\BladeStaticcacheStatsMiddleware::class,\n    ]);\n})\n\n```\n\n**For laravel 10.x and earlier:**\n\nAdd the middleware definition to the http kernel.\n\n\n```php\n// app/Http/Kernel.php\n\n...\n\nprotected $middlewareGroups = [\n   'web' =\u003e [\n       ...\n       \\SwissDevjoy\\BladeStaticcacheDirective\\BladeStaticcacheStatsMiddleware::class,\n   ],\n\n```\n\n## Cache Profile\n\nThe cache profile is responsible for generating the unique key for the cache entry. By default, it uses the `\\SwissDevjoy\\BladeStaticcacheDirective\\CacheProfile` class, which generates a key based on the cache key parameter passed to the `@staticcache` directive AND the current locale.\n\n## Inspiration\n\nThe main idea came from a tweet (https://x.com/dgurock/status/1577314908982706176) and the following package: https://github.com/ryangjchandler/blade-cache-directive\n\nI did some basic benchmarks with a huge template and a lot of data.\n\nUsing Ryan's package and `redis` as a cache driver, I got 85 req/s.\nUsing Ryan's package and `file` as a cache driver, I got 99 req/s.\nUsing my package, I got 110 req/s.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Dimitri König](https://github.com/dimitri-koenig)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiss-devjoy%2Fblade-staticcache-directive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiss-devjoy%2Fblade-staticcache-directive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiss-devjoy%2Fblade-staticcache-directive/lists"}