faysal0x1/service-worker-module
最新稳定版本:1.0.4
Composer 安装命令:
composer require faysal0x1/service-worker-module
包简介
Reusable service worker + frontend cache module for Laravel (nwidart).
README 文档
README
Reusable nwidart/laravel-modules package that ships:
- A production-ready
sw.jsimplementation with image/API caching helpers - Frontend utilities (
resources/js/utils/serviceWorker.js+ config helper) - Publishable config files (
config/service-worker.php,config/frontend-cache.php) - Documentation (
SERVICE_WORKER_CONFIG.md)
Installation
composer require faysal0x1/service-worker-module php artisan module:enable ServiceWorker
Publish assets
# Config + docs php artisan vendor:publish --provider="App\Modules\ServiceWorker\Providers\ServiceWorkerServiceProvider" --tag=serviceworker-config php artisan vendor:publish --provider="App\Modules\ServiceWorker\Providers\ServiceWorkerServiceProvider" --tag=serviceworker-docs # Frontend helpers php artisan vendor:publish --provider="App\Modules\ServiceWorker\Providers\ServiceWorkerServiceProvider" --tag=serviceworker-frontend # Optional: publish the service worker bootstrap + standalone worker file php artisan vendor:publish --provider="App\Modules\ServiceWorker\Providers\ServiceWorkerServiceProvider" --tag=serviceworker-assets
Frontend usage
import serviceWorkerManager from '@/utils/serviceWorker'; serviceWorkerManager.init(page.props); serviceWorkerManager.register();
The manager automatically shares configuration via Inertia props and exposes helpers for clearing caches, pushing config updates, etc.
Service worker route
The module registers GET /service-worker-module/sw.js, which serves the worker code.
The published public/sw.js bootstrap simply importScripts this route, so the worker
always stays in sync with the module.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-11