返回提示词目录第 1373 页

渐进式网页应用可靠性审计

检查应用安装、离线同步、缓存隔离与版本更新行为,输出有证据的可靠性缺陷和验证结论。

完整提示词

I want you to perform an exhaustive, systematic, and evidence-first analysis of the entire Progressive Web App implementation.

Main goal:

> Determine whether the application genuinely operates as a reliable PWA under realistic conditions, including installation, offline behavior, caching strategy, update lifecycle, user data security, and divergent browser/platform scenarios.

This is not:

- a generic PWA checklist
- merely checking `manifest.json`
- merely checking whether a service worker exists
- automatically declaring an application "PWA ready"
- dumping everything into cache blindly
- a generic recommendation to "add an offline mode"
- a superficial Lighthouse review

The focus is on real runtime behavior.

Priority:

**correctness > update safety > data isolation > offline reliability > installability > performance**

The most critical risk with a PWA is not simply that a feature fails offline.

A far more dangerous hazard is:

> a user receives stale, incorrect, or private data belonging to another user due to a flawed caching strategy.

---

# 1. IDENTIFY PWA STACK

Before filing findings, determine:

- framework
- browser target matrix
- PWA library if present
- custom service worker vs generated service worker
- Workbox if present
- manifest file location
- registration mechanism
- cache storage usage
- IndexedDB usage
- localStorage usage
- background sync implementation
- push notifications
- install prompt flow
- offline fallback mechanism
- deployment platform

Locate and inspect:

- `manifest.json`
- `manifest.webmanifest`
- service worker file
- Workbox configuration
- PWA plugin configuration
- service worker registration call
- cache versioning logic
- install UI
- offline UI
- update notification UI
- push notification handlers
- background sync triggers

---

# 2. DETERMINE WHETHER PWA IS AN INTENDED CORE FEATURE

Do not assume that the mere presence of a manifest means the application aims to be an offline-first platform.

Identify the intended product model:

- installable web app
- partial offline support
- offline-first
- online-first with graceful offline fallback
- standard web app with a web app manifest

All recommendations must align with this deliberate product scope.

---

# 3. MAP PWA ARCHITECTURE

Diagram the actual execution flow:

```text
Browser
↓
App shell
↓
Service Worker
↓
Cache Storage
↓
Network
↓
API
↓
IndexedDB / local state
```

If synchronization exists:

```text
User action
↓
local persistence
↓
offline queue
↓
network reconnect
↓
sync
↓
server
↓
conflict handling
↓
UI reconciliation
```

If update mechanisms exist:

```text
new deployment
↓
new service worker downloaded
↓
install
↓
waiting
↓
activation
↓
old/new client interaction
↓
user reload
```

Do not analyze PWA files in isolation.

---

# 4. MANIFEST AUDIT

Inspect the complete web manifest.

Verify:

- `name`
- `short_name`
- `start_url`
- `scope`
- `display`
- `display_override`
- `background_color`
- `theme_color`
- icons
- maskable icons
- orientation if present
- shortcuts if present
- screenshots if present
- categories if present
- share target if present
- file handlers if present

Do not report optional manifest properties as missing defects without justification.

---

# 5. `start_url`

Verify that installed applications launch into the correct entry point.

Look for:

- hardcoded development URLs
- incorrect locale prefixes
- auth-restricted URLs that cause immediate bounce
- query parameters that mutate runtime behavior
- URLs falling outside the manifest `scope`

---

# 6. `scope`

Inspect the relationship:

```text
start_url
scope
routes
```

Ask:

> Can a user in an installed app unexpectedly navigate outside the PWA scope during routine usage?

If yes, evaluate the consequences.

---

# 7. DISPLAY MODE

If using:

```text
standalone
fullscreen
minimal-ui
```

verify that the UI and navigation controls account for that display environment.

A standalone app lacks standard browser back/forward buttons and URL bars.

---

# 8. ICONS

Check:

- required dimensions
- valid image assets
- asset paths
- transparency vs background contrast
- maskable icon support where required

Do not treat every missing optional icon dimension as a severe defect.

---

# 9. MASKABLE ICONS

If an icon is not adapted for adaptive masking, OS launchers may crop critical branding elements.

Inspect the actual icon graphic.

---

# 10. THEME COLOR

Check consistency across:

- manifest
- HTML metadata tags
- light theme
- dark theme

Do not treat minor cosmetic color variances as major defects.

---

# 11. SERVICE WORKER REGISTRATION

Pinpoint exactly where the service worker is registered.

Verify:

- timing of registration
- registration script URL
- registration scope
- error handling
- duplicate registration attempts
- environment guards

---

# 12. DEVELOPMENT VS PRODUCTION

A service worker active during local development can severely disrupt debugging.

Verify registration scoping:

- production only
- development
- preview environments

according to intentional architectural strategy.

---

# 13. STALE SERVICE WORKERS

Specifically analyze this lifecycle transition:

```text
old deployment
↓
old service worker active
↓
new application deployed
↓
browser still controlled by old worker
```

Ask:

> Can users remain trapped on a stale application version longer than intended?

---

# 14. SERVICE WORKER LIFECYCLE

Trace:

```text
register
↓
installing
↓
installed
↓
waiting
↓
activating
↓
activated
```

Verify how the application handles each lifecycle state.

---

# 15. WAITING SERVICE WORKER

If a newly installed worker remains in the waiting state, determine whether the user:

- receives an update prompt
- must close all open tabs to activate
- remains executing obsolete JavaScript bundles

---

# 16. `skipWaiting`

If utilizing:

```text
skipWaiting()
```

evaluate the risks.

Immediate automatic activation without client coordination is not always safe.

Failure pattern:

```text
old page JS
+
new service worker
```

operating under incompatible runtime assumptions.

---

# 17. `clientsClaim`

If using:

```text
clients.claim()
```

ensure the new service worker does not unexpectedly seize control of active, un-reloaded legacy clients containing stale assets.

---

# 18. MIXED VERSION PROBLEM

One of the most insidious PWA failure modes.

Scenario:

```text
HTML v1
↓
JS v1
↓
service worker v2 activates
↓
API/cache behavior v2
```

or:

```text
HTML v2
↓
cached JS v1
```

Verify whether such version skew can occur in practice.

---

# 19. UPDATE STRATEGY

Determine the implemented update model:

- automatic background update
- user prompt banner
- automatic reload
- reload upon subsequent visit
- no explicit update handling

Evaluate whether this matches the application profile.

---

# 20. UPDATE NOTIFICATION

If the UI displays:

```text
A new version is available
```

verify:

- whether the prompt only appears when a worker is genuinely waiting
- what the update action button does
- whether reload is safe
- whether users can lose unsaved form state

---

# 21. UNSAVED DATA DURING UPDATES

Scenario:

```text
user fills long form
↓
new version detected
↓
app auto reloads
↓
form data lost
```

If automatic reloads exist, evaluate this risk.

---

# 22. CACHE INVENTORY

Map every cache instance.

For each, document:

```text
Cache name:
Purpose:
Contents:
Strategy:
Expiration:
Invalidation:
User-specific:
```

---

# 23. CACHE VERSIONING

Inspect how cache buckets are versioned.

Look for:

- hardcoded cache names that never rotate
- build version tags
- asset hash identifiers
- runtime caches

---

# 24. OLD CACHE CLEANUP

During the `activate` lifecycle phase, verify that obsolete cache stores are deleted.

Avoid deleting active runtime caches that still serve a legitimate purpose.

---

# 25. CACHE GROWTH

Runtime caches can grow boundlessly.

Inspect:

- max entries limits
- expiration TTLs
- URL parameter cardinality
- image and API cache retention

---

# 26. CACHE STRATEGIES

For every resource category, define the strategy:

- Cache First
- Network First
- Stale While Revalidate
- Network Only
- Cache Only

Evaluate whether each strategy fits the data semantics.

---

# 27. CACHE FIRST

Good candidate:

- versioned, immutable static assets

Dangerous candidate without explicit invalidation:

- rapidly mutating user data

Report only concrete misapplications.

---

# 28. NETWORK FIRST

Inspect:

- network timeout thresholds
- offline fallback behavior
- cache write updates

If the network request never times out, users on slow/unstable connections endure long delays before falling back to cached responses.

---

# 29. STALE WHILE REVALIDATE

Ideal for public, non-sensitive resources.

Hazardous for:

- permissions
- account status
- financial records
- user-private data

Analyze semantic freshness requirements.

---

# 30. PRECACHE

Map precached assets.

Look for:

- oversized asset bundles
- unnecessary deep routes
- user-specific content
- excessive install download payloads

---

# 31. APP SHELL

If using an app shell architecture, verify that the shell truly renders offline without external network calls.

---

# 32. OFFLINE FALLBACK

Determine what users observe when connectivity drops completely.

Possible models:

- cached content
- dedicated offline fallback page
- degraded partial UI
- generic browser connection error

---

# 33. OFFLINE PAGE

If a dedicated offline page is provided, verify whether it is precached.

Common failure:

the offline fallback page exists in code, but is never cached and therefore unreachable offline.

---

# 34. NAVIGATION REQUESTS

Specifically examine how the service worker resolves navigation requests.

Look for scenarios where:

```text
navigate /dashboard
↓
network offline
↓
worker serves incorrect cached document
```

---

# 35. SPA FALLBACK

If the service worker serves `index.html` for all navigation requests, verify:

- 404 error behavior
- API request separation
- static asset separation
- server-rendered route compatibility

Do not impose an SPA fallback model onto multi-page architectures.

---

# 36. CACHED 404

Ensure the service worker never caches a 404 response as a valid resource.

---

# 37. CACHED 500

Ensure the service worker never caches internal server error responses.

---

# 38. RESPONSE VALIDATION

Before calling `cache.put()`, verify that HTTP response statuses are validated (`response.ok` or explicit status codes).

---

# 39. API CACHING

Construct an API cache matrix:

| Endpoint | Method | User-specific | Cache strategy | TTL | Risk |
|---|---|---|---|---|---|

---

# 40. GET IS NOT AUTOMATICALLY SAFE TO CACHE

A GET endpoint may expose:

- private user profiles
- authentication states
- sensitive permission scopes
- rapidly changing balances

Analyze data sensitivity, not merely the HTTP verb.

---

# 41. AUTHENTICATED CACHE

The single most critical PWA security question:

> Can a cached response belonging to User A be served to User B?

Trace this flow:

```text
User A logs in
↓
GET /api/profile
↓
service worker caches response
↓
User A logs out
↓
User B logs in
↓
same URL requested
↓
cached User A response returned
```

If possible, this represents a severe security flaw.

---

# 42. LOGOUT CACHE CLEANUP

Verify what happens to cached private data upon user logout.

Map:

- Cache Storage
- IndexedDB
- localStorage
- client-side query caches
- in-memory state

---

# 43. ACCOUNT SWITCHING

Scenario:

```text
Account A
↓
offline cache populated
↓
logout
↓
Account B logs in
```

Verify that cross-account data leakage is impossible.

---

# 44. MULTI-TENANT CACHE

In multi-tenant applications, cache keys must strictly incorporate the tenant context.

Scrutinize URLs that do not include the tenant identifier when the response payload is tenant-specific.

---

# 45. AUTH TOKENS

Ensure the service worker does not:

- log tokens to console
- store authorization headers in un-scoped caches
- transmit tokens to unauthorized origins

---

# 46. CACHE KEY

Determine what establishes cache identity.

A URL alone is insufficient if the response varies based on:

- user identity
- active locale
- tenant identifier
- custom authorization headers

---

# 47. `Vary`

If caching behavior depends on HTTP headers, verify `Vary` header processing where relevant.

---

# 48. POST REQUESTS

Service workers must never generically cache POST requests.

If POST requests are queued for background synchronization, analyze that queue logic separately.

---

# 49. OFFLINE WRITES

If the application supports offline mutations, trace:

```text
user action
↓
local mutation
↓
queue
↓
offline persistence
↓
reconnect
↓
server mutation
```

---

# 50. OFFLINE QUEUE PERSISTENCE

Verify that the mutation queue survives:

- page reloads
- browser restarts
- device reboots

if offline write reliability is an advertised feature.

---

# 51. DUPLICATE SYNC

Scenario:

```text
queued mutation
↓
network returns
↓
sync triggers
↓
application also retries manually
↓
identical mutation dispatched twice
```

Verify idempotency protections.

---

# 52. BACKGROUND SYNC

If Background Sync API is used, verify:

- browser support matrix
- fallback mechanisms
- retry backoff policies
- duplicate execution guards
- user progress feedback

Do not assume universal browser support.

---

# 53. IDEMPOTENCY

For queued offline writes, scrutinize:

- record creation
- payments
- messaging
- file uploads
- deletions

If retrying an operation causes duplicate side-effects, report a serious reliability defect.

---

# 54. CONFLICT RESOLUTION

Scenario:

```text
Device A edits record offline
Device B edits same record online
Device A reconnects
```

What occurs?

Possible models:

- last-write-wins
- optimistic concurrency check
- conflict resolution prompt
- field-level merge

Document the application's actual behavior.

---

# 55. LOST UPDATE

Without concurrency or version checking, an offline sync will silently overwrite newer server modifications.

---

# 56. TIMESTAMPS

Do not rely blindly on client device clocks for conflict resolution ordering.

Device clocks can be inaccurate or manipulated.

---

# 57. SYNC STATUS

Users must understand whether an item is:

- pending sync
- actively synchronizing
- sync failed
- successfully persisted to server

where offline writing is a core feature.

---

# 58. FALSE SUCCESS

Severe reliability defect:

```text
offline mutation
↓
UI indicates Saved
↓
queue subsequently fails permanently
```

If the user is never alerted, data loss has effectively occurred.

---

# 59. RETRY POLICY

Inspect:

- max retry attempts
- exponential backoff
- handling of permanent 4xx errors
- handling of authentication 401 errors
- handling of validation 422 errors

An HTTP 400 Bad Request should not be retried infinitely like a transient network timeout.

---

# 60. AUTH EXPIRATION DURING OFFLINE PERIODS

Scenario:

```text
user goes offline
↓
session token expires
↓
user queues mutations
↓
network reconnects
↓
server returns 401 Unauthorized
```

How does the application safeguard pending queued data?

---

# 61. STORAGE INVENTORY

Map all local client-side storage:

- Cache Storage
- IndexedDB
- localStorage
- sessionStorage

For each stored item, identify:

- ownership
- data sensitivity
- lifetime
- schema version
- cleanup triggers

---

# 62. INDEXEDDB VERSIONING

If data schemas evolve, verify migration procedures (`onupgradeneeded`).

An installed PWA may run on an outdated local database version.

---

# 63. LOCAL DB MIGRATION

Scenario:

```text
user does not launch app for 6 months
↓
multiple releases deploy
↓
user launches latest release
↓
local DB is several migrations behind
```

Verify migration chain execution.

---

# 64. CORRUPTED LOCAL DATA

Verify behavior when:

- an IndexedDB record is malformed
- localStorage contains invalid JSON
- old schema data cannot be parsed

The application must not crash permanently into an unrecoverable state.

---

# 65. STORAGE QUOTA

A large offline cache or dataset can exhaust browser storage quotas.

Check:

- quota error handling
- eviction policies
- user alerts

Do not quote exact megabyte limits as they depend on platform and disk availability.

---

# 66. STORAGE EVICTION

Browsers may evict client storage under storage pressure.

If the application treats local storage as an authoritative permanent datastore, analyze data-loss risks.

---

# 67. PERSISTENT STORAGE

If requesting the Persistent Storage API, verify:

- platform support
- fallback logic

Never assume persistent storage requests are always granted.

---

# 68. OFFLINE FILES

If the application caches:

- PDFs
- high-res images
- audio files
- video assets

verify storage consumption controls.

---

# 69. MEDIA RANGE REQUESTS

When caching video or audio files, verify HTTP Range request handling.

Naive caching of 206 Partial Content responses can break media seeking and playback.

---

# 70. IMAGE CACHE

Check:

- expiration rules
- maximum entry limits
- transformed image URL cardinality

---

# 71. THIRD-PARTY RESOURCES

If the service worker caches cross-origin resources:

- web fonts
- third-party images
- analytics scripts
- external APIs

verify:

- CORS headers
- opaque responses
- storage cost implications
- actual utility

---

# 72. OPAQUE RESPONSES

Opaque responses cannot be inspected and carry heavily inflated storage padding in browser caches.

Do not cache opaque responses indiscriminately.

---

# 73. CDN AND SERVICE WORKER

Map interactions between two caching tiers:

```text
browser
↓
service worker cache
↓
CDN edge cache
↓
origin server
```

Look for extreme staleness created by compounding cache layers.

---

# 74. CACHE INVALIDATION POST-DEPLOYMENT

Verify that hashed asset filenames update upon content modification.

For unhashed assets, verify explicit cache revalidation.

---

# 75. HTML CACHING

Exercise extreme caution when caching HTML or navigation responses.

Cached HTML may reference JavaScript bundles that have been purged from production hosts.

---

# 76. ASSET 404 AFTER DEPLOYMENT

Scenario:

```text
old HTML cached
↓
new deployment purges old JS chunks
↓
browser requests old JS chunk
↓
server returns 404
↓
app crashes during startup
```

Verify hosting and asset retention policies.

---

# 77. CHUNK LOAD ERRORS

If an application encounters chunk version mismatches, verify recovery behavior.

Avoid triggering infinite reload loops.

---

# 78. RELOAD RECOVERY

If chunk loading failures trigger window reloads, verify:

- loop prevention guards (e.g. session flag)
- preservation of unsaved user inputs
- clearing of corrupt caches

---

# 79. OFFLINE AUTHENTICATION STATE

Verify what is displayed to an authenticated user when offline.

Avoid displaying:

```text
Session expired
```

merely because the authentication server could not be reached.

Distinguish:

- state unknown
- client offline
- authenticated session definitively terminated

---

# 80. PRIVATE DATA OFFLINE

If sensitive data remains accessible offline, verify whether this is an intentional product feature.

Evaluate privacy risks on shared or public workstations.

---

# 81. DEVICE SHARING

User logout must purge locally stored private records if the threat model requires data isolation.

---

# 82. APP INSTALLABILITY

If tooling allows, test live installability criteria.

Do not rely solely on the existence of a manifest file.

---

# 83. INSTALL UI

If a custom "Install App" button is implemented, verify:

- when it surfaces
- behavior when the browser does not support installation
- behavior post-installation
- whether it reappears redundantly

---

# 84. `beforeinstallprompt`

If utilized, verify browser support and fallback behavior.

Do not assume the event fires across all browsers.

---

# 85. INSTALLED STATE

Verify how the application detects standalone or installed display modes (`display-mode: standalone`).

Look for fragile platform-specific assumptions.

---

# 86. DUPLICATE INSTALL CTA

If the browser already presents a native install badge, an aggressive custom modal may be redundant.

Classify as UX improvement, not an intrinsic bug.

---

# 87. IOS INSTALLATION

If targeting iOS Safari, verify that the application does not assume Chromium-style install events.

Document platform-specific install flows (e.g. Add to Home Screen instructions).

---

# 88. ANDROID INSTALLATION

Verify Android browser behaviors within the target device portfolio.

---

# 89. STANDALONE NAVIGATION

In installed standalone mode, verify whether external links:

- stay within the standalone window
- launch in the system browser

Ensure behavior aligns with intended user experience.

---

# 90. EXTERNAL LINKS

Test third-party authentication and payment flows initiated from standalone PWAs.

---

# 91. OAUTH IN PWAS

Scrutinize the OAuth flow:

```text
installed app
↓
OAuth provider in browser/tab
↓
callback redirect
↓
return to installed app
```

Ensure authentication does not break due to isolated browser/standalone storage contexts.

---

# 92. PAYMENT FLOWS

If payment redirects to an external gateway, verify seamless return to the standalone PWA.

---

# 93. DEEP LINKS

Test opening a deep link directly:

```text
/product/123
```

inside an installed PWA.

Does the application route accurately?

---

# 94. SHARE TARGET

If Web Share Target is declared, verify:

- manifest declaration
- input data validation
- handling of unsupported file payloads
- duplicate processing guards

If not implemented:

**NOT APPLICABLE**

---

# 95. WEB SHARE

If using the Web Share API, verify fallback behavior for browsers lacking support.

---

# 96. FILE HANDLERS

If the PWA registers file handling capabilities, verify:

- MIME type restrictions
- file extension filters
- payload validation
- security boundaries

If not implemented:

**NOT APPLICABLE**

---

# 97. PROTOCOL HANDLERS

If custom URL protocols are registered, verify input sanitization.

---

# 98. PUSH NOTIFICATIONS

If web push is supported, map:

```text
permission prompt
↓
subscription creation
↓
server registration
↓
push event
↓
service worker
↓
notification displayed
↓
notification click
↓
client navigation
```

---

# 99. NOTIFICATION PERMISSION

Do not prompt for notification permissions immediately upon initial page load without context.

Report aggressive permission prompts as UX defects.

---

# 100. PUSH SUBSCRIPTION

Check:

- subscription rotation
- unsubscribe handling
- expired subscription cleanup
- duplicate subscription prevention
- user-to-endpoint association

---

# 101. LOGOUT AND PUSH

Scenario:

```text
User A subscribes to notifications
↓
User A logs out
↓
User B logs in on same device
```

Verify that User B does not receive notification alerts intended for User A.

---

# 102. PUSH PAYLOAD

Do not expose sensitive personal information in raw notification payloads.

Device lock screens often display notifications publicly.

---

# 103. NOTIFICATION CLICK

Verify:

- routing to the relevant view
- focusing an existing open window/client
- handling new window instantiation
- preventing duplicate tab sprawl

---

# 104. MULTIPLE CLIENTS

A service worker may control multiple concurrent tabs or windows.

Verify state broadcast and update logic (`postMessage` / `BroadcastChannel`).

---

# 105. CLIENT MESSAGING

When the worker and client pages communicate via `postMessage`, verify:

- message schema validation
- handling of unrecognized message types
- handling of stale client messages
- version compatibility

---

# 106. MESSAGE VERSIONING

If an older page communicates with a newer service worker, message protocols may diverge.

Include versioning markers in message contracts where necessary.

---

# 107. BACKGROUND FETCH

If implemented, verify browser support and fallback logic.

If not implemented:

**NOT APPLICABLE**

---

# 108. PERIODIC BACKGROUND SYNC

Do not rely on Periodic Background Sync for critical application functionality without fallback architectures.

---

# 109. CONNECTIVITY DETECTION

`navigator.onLine` does not guarantee actual internet or API reachability.

If treated as an authoritative check, evaluate false-positive and false-negative scenarios.

---

# 110. ONLINE EVENT

Scenario:

```text
online event fires
↓
app initiates sync
↓
API is still unreachable
```

Sync logic must incorporate standard error handling and backoff.

---

# 111. OFFLINE EVENT

Network requests can fail while the browser reports an online state.

Do not depend solely on connectivity events.

---

# 112. UX STATUS

Ensure users can clearly distinguish between:

- offline
- online
- synchronizing
- sync failed
- stale cached data

where critical.

---

# 113. STALE DATA LABELING

If displaying cached historical data offline, evaluate whether the user should be shown the last synchronized timestamp.

---

# 114. TIME-SENSITIVE DATA

Never cache the following long-term without strict revalidation policies:

- inventory availability
- pricing
- authorization permissions
- financial balances

---

# 115. CLOCK/TIMEZONE

If presenting "last synced X minutes ago", verify timezone calculations and avoid fragile client clock assumptions.

---

# 116. FORM OFFLINE BEHAVIOR

When a user submits a form while offline, determine the outcome:

- queued for background sync
- clear error message
- network error dialog
- form data preserved

Worst-case failure:

```text
submit
↓
network failure
↓
form resets
↓
user inputs erased
```

---

# 117. DRAFT PERSISTENCE

If draft safety is an advertised feature, verify:

- auto-save timing
- local storage persistence
- draft purging upon successful submission
- schema migration for drafts

---

# 118. FILE UPLOAD OFFLINE

If file uploads cannot be queued offline, the interface must state this clearly and preserve the selected file reference without silent loss.

---

# 119. LARGE UPLOADS

Background sync is generally unsuited for massive file uploads.

Evaluate platform limits.

---

# 120. NAVIGATION OFFLINE

Test three distinct navigation cases:

### A

Page was previously visited while online.

### B

Page was never visited previously.

### C

App shell is cached, but API data is unavailable.

Document outcomes for each.

---

# 121. HARD REFRESH OFFLINE

Critical test:

```text
open cached route
↓
disconnect network
↓
trigger hard refresh (Ctrl+F5 / Cmd+Shift+R)
```

Many web apps appear offline-capable until a hard refresh bypasses in-memory state.

---

# 122. DIRECT URL OFFLINE

Test deep link entry:

```text
close browser
↓
disconnect network
↓
navigate directly to deep URL
```

Verify whether the application boots correctly.

---

# 123. NEW INSTALL OFFLINE

A fresh installation on a clean device without prior caching cannot magically manifest offline content.

Do not report this as a defect if not an advertised feature.

---

# 124. SERVICE WORKER ERROR HANDLING

Inspect:

- install phase failures
- `cache.add` / `cache.addAll` rejections
- fetch event listener exceptions
- activate phase errors

An uncaught exception in a service worker can disable offline functionality entirely.

---

# 125. `cache.addAll`

If a single asset listed in `cache.addAll` fails to download (e.g. 404), the entire precache install fails.

Verify the precache manifest generation.

---

# 126. OPTIONAL ASSETS

Never let non-critical assets (e.g. decorative promotional banners) abort service worker installation.

---

# 127. FETCH HANDLER

Inspect the routing rules inside `fetch` event listeners.

Look for overly broad request interception patterns.

---

# 128. API VS STATIC REQUESTS

The service worker must differentiate:

- navigation documents
- static assets
- API endpoints
- images
- third-party requests

Applying a single cache strategy across all request types creates systemic defects.

---

# 129. REQUEST METHOD

Verify that fetch handlers explicitly check HTTP methods (`GET` vs mutations).

---

# 130. RANGE / STREAMING REQUESTS

Ensure streaming and Range requests for media assets are handled cleanly.

---

# 131. REQUEST HEADERS

If server responses vary based on headers, simplistic URL cache keys will produce data collisions.

---

# 132. LOCALE CACHING

Scenario:

```text
/en/page
/fr/page
```

or identical URLs with locale headers/cookies.

Verify that caches do not serve cross-language content.

---

# 133. THEME / PERSONALIZATION

If server responses adapt based on theme or personalization cookies, verify cached HTML behavior.

---

# 134. A/B TEST CACHING

If responses depend on experiment flags, service worker caching can permanently lock users into incorrect experiment variants.

---

# 135. SECURITY HEADERS

A service worker does not negate the necessity of standard web security headers.

Verify that caching layers do not bypass required authentication boundaries.

---

# 136. HTTPS

Service workers require a secure context (HTTPS), except on `localhost`.

Verify production HTTPS enforcement.

---

# 137. SERVICE WORKER SCOPE SECURITY

An overly broad service worker scope can intercept requests intended for adjacent applications hosted on the same origin.

---

# 138. MULTIPLE SERVICE WORKERS

If multiple applications or workers exist on the same origin, inspect potential scope collisions.

---

# 139. SERVICE WORKER FILE LOCATION

The physical location of the service worker script defines its default maximum scope.

Verify deployment paths.

---

# 140. CDN SERVICE WORKER CACHE

The service worker script itself must not be cached aggressively by CDN or browser HTTP headers (`max-age=0` or `no-cache` recommended).

Caching the worker script delays critical security and bug fixes.

---

# 141. SERVICE WORKER RESPONSE HEADERS

Inspect response headers served for the service worker file.

---

# 142. UPDATE CHECK FREQUENCY

Ensure the application does not rely on infrequent worker update checks when rapid deployment updates are essential.

---

# 143. MANUAL UPDATE CHECK

If the application maintains long-lived active sessions, verify whether it periodically triggers `registration.update()` where appropriate.

Avoid aggressive polling loops.

---

# 144. LONG-LIVED TABS

Scenario:

```text
dashboard left open for 3 days
↓
multiple production releases deployed
```

What does the user experience?

---

# 145. BACKWARD API COMPATIBILITY

A legacy PWA client may continue calling newly deployed backend APIs.

Deployment strategies must never require instantaneous client-side updates.

This is critical.

---

# 146. CLIENT/SERVER VERSION SKEW

Map:

```text
frontend v1
backend v2
```

and vice versa.

Inspect:

- API contracts
- newly required request fields
- deprecated response fields
- enumeration changes

---

# 147. DATABASE MIGRATION VS OLD CLIENTS

An older installed client will dispatch mutations adhering to the previous schema contract following a database migration.

Verify backward compatibility handling on the server.

---

# 148. FORCED UPDATES

If an application enforces a minimum client version, inspect how it is implemented.

Do not suggest forced updates without business necessity.

---

# 149. OFFLINE SCHEMA COMPATIBILITY

A newly deployed client must safely open locally persisted records created by previous versions.

Verify migration and validation logic.

---

# 150. MULTI-VERSION DATA

A mutation queued in v1 may be processed by the worker when v3 is active.

Verify that the payload structure remains compatible.

---

# 151. ANALYTICS OFFLINE

If analytics events are queued offline, inspect:

- duplicate dispatches
- timestamp skew
- privacy retention
- queue size caps

---

# 152. LOGGING

Service worker exceptions are rarely captured by standard client-side error reporting libraries.

Verify observability architecture.

---

# 153. SERVICE WORKER OBSERVABILITY

Determine whether developers can diagnose:

- installation failures
- activation failures
- cache lookup failures
- sync failures
- push delivery failures

---

# 154. ERROR TRACKING

If service worker error reporting is absent, evaluate whether application complexity justifies dedicated instrumentation.

---

# 155. TESTING

Review existing PWA test coverage.

Look for tests covering:

- installation
- updates
- offline functionality
- stale cache invalidation
- logout cleanup
- hard refresh behavior
- failed sync handling

---

# 156. UNIT TEST LIMITATIONS

Unit testing service worker logic in isolation does not guarantee correct browser lifecycle behavior.

Integration and E2E tests are essential for reliable verification.

---

# 157. E2E OFFLINE TEST

Where tooling permits, test:

```text
load application online
↓
cache established
↓
disable network emulation
↓
navigate across routes
↓
refresh
```

---

# 158. UPDATE E2E TEST

Test flow:

```text
run v1
↓
deploy/build v2
↓
detect waiting worker
↓
trigger activation
↓
reload
↓
verify v2 active
```

---

# 159. LOGOUT E2E TEST

Test flow:

```text
login User A
↓
load private data
↓
offline cache populated
↓
logout
↓
login User B
↓
verify zero User A data visible
```

---

# 160. SYNC E2E TEST

For offline mutations:

```text
disconnect network
↓
create or edit record
↓
close and reopen app
↓
reconnect network
↓
trigger sync
↓
verify server records exactly one entry
```

---

# 161. INSTALLABILITY TEST

If not tested at runtime:

```text
INSTALLABILITY: NOT VERIFIED
```

Do not assert that an app is installable purely because its manifest looks valid in source code.

---

# 162. PLATFORM MATRIX

Where relevant, construct:

| Capability | Chromium Desktop | Android | iOS/Safari | Other Target | Result |
|---|---|---|---|---|---|

Do not invent runtime results without empirical testing.

---

# 163. CAPABILITY DETECTION

Verify feature detection for optional Web APIs.

Avoid fragile user-agent sniffing.

---

# 164. FALLBACKS

For every optional PWA capability, ask:

> What happens if this Web API is unsupported?

---

# 165. GRACEFUL DEGRADATION

PWA capabilities must enhance the application; the core web product must remain functional without them.

---

# 166. PWA-ONLY ASSUMPTION

If a website functions only when a service worker is active, evaluate whether this dependency is deliberate and safe.

---

# 167. ACCESSIBILITY

Inspect PWA-specific UI elements:

- install prompts
- update notification banners
- offline status indicators
- sync status badges
- permission modals

for:

- keyboard accessibility
- screen reader announcements
- focus management

---

# 168. UPDATE BANNER FOCUS

An update notification banner must not aggressively hijack focus away from an active user input task.

---

# 169. OFFLINE BANNER

Ensure offline status is not conveyed solely through color cues.

---

# 170. NOTIFICATION ACCESSIBILITY

Notification content must make sense without visual context.

---

# 171. PERFORMANCE

Inspect PWA-specific performance risks:

- oversized precache lists
- redundant network + cache requests
- cache lookup latency
- bloated client storage

Do not turn this into a general performance audit.

---

# 172. INSTALL PAYLOAD

Calculate or estimate the total byte size downloaded during initial install/precache.

If unmeasured:

**NOT MEASURED**

---

# 173. PRECACHE DUPLICATION

Ensure identical assets are not cached redundantly across multiple cache stores.

---

# 174. CACHE STORAGE SIZE

If tooling allows, measure actual cache consumption.

Otherwise:

**NOT MEASURED**

---

# 175. PRIVACY

Map all sensitive personal information stored locally:

- health records
- financial transactions
- personal communications
- auth tokens

Do not assume browser storage provides encryption-at-rest guarantees.

---

# 176. SHARED DEVICE MODEL

If the application manages sensitive records, evaluate the shared-workstation scenario.

---

# 177. CLEAR SITE DATA

Verify whether logging out or deleting an account cleanses client-side storage.

---

# 178. ACCOUNT DELETION

Scenario:

```text
account deleted server-side
↓
cached offline data remains on device
```

Evaluate privacy expectations.

---

# 179. DATA RETENTION

Runtime cache expiration is a privacy decision as well as a performance choice when caching user data.

---

# 180. PWA SECURITY BOUNDARY

A service worker operates with broad privileges within its assigned scope.

Review script integrity and origin restrictions.

---

# 181. EXTERNAL SERVICE WORKER SCRIPTS

If a service worker imports remote scripts:

```js
importScripts(...)
```

evaluate supply-chain security risks.

---

# 182. `importScripts`

Verify:

- script origin
- cryptographic hash pinning
- explicit purpose
- failure behavior

---

# 183. CSP

If a Content Security Policy is defined, inspect interactions with service worker scripts and PWA assets.

---

# 184. SERVICE WORKER FETCH SECURITY

A fetch handler must never act as an open, unvalidated proxy for arbitrary user-controlled URLs.

---

# 185. OPEN PROXY / SSRF-LIKE PATTERNS

If the service worker fetches arbitrary URLs passed via `postMessage`, inspect trust boundaries.

---

# 186. CACHE POISONING

If untrusted data or arbitrary URLs can enter a trusted cache store, evaluate whether they could later be served as legitimate application resources.

---

# 187. MESSAGE TRUST

Ensure service worker message handlers validate message origin, structure, and source windows.

---

# 188. FINDING FORMAT

Every serious finding must include:

```text
ID:
Severity:
Category:
Confidence:
Status:
 
Capability:
Route/Resource:
Cache:
Service Worker location:
File:
Relevant code:
 
Problem:
 
Evidence:
 
Runtime flow:
 
Offline/Update reproduction:
 
Expected behavior:
 
Actual behavior:
 
User impact:
 
Data/Security impact:
 
Root cause:
 
Recommended remediation:
 
Verification:
 
Regression test:
 
Complexity:
XS / S / M / L / XL
```

If a field is not applicable:

**NOT APPLICABLE**

---

# 189. SEVERITY

Use:

## P0 - CRITICAL

- cross-user leakage of private cached data
- catastrophic data loss
- service worker defects critically compromising site availability

## P1 - HIGH

- users locked on obsolete, incompatible client versions
- lost offline mutations
- duplicate execution of critical mutations
- major cache privacy flaws
- unreliable application updates

## P2 - MEDIUM

- significant offline, update, or install defects of bounded scope
- stale data causing tangible user consequences

## P3 - LOW

- localized PWA bug or platform compatibility gap

## P4 - IMPROVEMENT

- PWA UX or capability optimization that does not represent a functional bug

---

# 190. CONFIDENCE

Use:

```text
HIGH
MEDIUM
LOW
```

HIGH:

reproduced at runtime or proven directly through service worker/cache logic.

MEDIUM:

strong implementation evidence, but browser lifecycle was not validated at runtime.

LOW:

depends on unverified browser/platform behaviors or unavailable production configurations.

---

# 191. STATUS

Use:

```text
CONFIRMED
LIKELY
THEORETICAL
NOT VERIFIED
```

---

# 192. BROWSER-SPECIFIC CLAIMS

Never present the behavior of a single browser engine as universal PWA behavior.

If target platforms were not tested:

**PLATFORM BEHAVIOR: NOT VERIFIED**

---

# 193. FRAMEWORK-AWARE ANALYSIS

If a framework or plugin generates the service worker, inspect its configuration and generated output before reporting issues.

Do not report missing boilerplate if the underlying plugin implements it automatically.

---

# 194. FALSE-POSITIVE PREVENTION

Before confirming a finding, review:

1. service worker source
2. generated build output
3. framework/plugin configuration
4. registration scripts
5. runtime caching rules
6. server and CDN cache headers
7. authentication flows
8. logout cleanup routines
9. deployment versioning strategy
10. test suites

Do not draw conclusions solely from `manifest.json`.

---

# 195. DO NOT MODIFY CODE

During the audit:

- do not edit service worker scripts
- do not purge caches
- do not alter manifests
- do not inject `skipWaiting`
- do not modify storage schemas
- do not install PWA plugins

Complete the audit first.

---

# 196. OUTPUT - PWA_AUDIT.md

Structure the final report as follows:

## 1. Executive Summary

- PWA architecture model
- installability status
- offline capability
- update strategy
- highest-priority risks
- positive implementations
- runtime verified scope

## 2. PWA Architecture

## 3. Manifest Audit

## 4. Service Worker Lifecycle

## 5. Update Strategy

## 6. Cache Inventory

Table:

| Cache | Content | Strategy | User-specific | Expiration | Risk |
|---|---|---|---|---|---|

## 7. Static Asset Caching

## 8. Navigation Caching

## 9. API Caching

## 10. Authentication & Cache Isolation

## 11. Offline Read Behavior

## 12. Offline Write / Sync Behavior

## 13. IndexedDB / Local Persistence

## 14. Installability

## 15. Standalone Mode

## 16. Push Notifications

If present.

## 17. Background Capabilities

If present.

## 18. Update Compatibility

## 19. Client/Server Version Skew

## 20. Privacy & Security

## 21. Performance

## 22. Platform Compatibility

## 23. Existing Test Coverage

## 24. Findings Summary

| ID | Severity | Category | Problem | Confidence | Status |
|---|---|---|---|---|---|

## 25. P0 Findings

## 26. P1 Findings

## 27. P2 Findings

## 28. P3 Findings

## 29. P4 Improvements

## 30. Things Done Well

## 31. Unknown / Not Verified

## 32. Remediation Roadmap

---

# 197. PWA PRODUCTION READINESS CHECKLIST

Use:

```text
✅ PASS
⚠️ PARTIAL
❌ FAIL
❓ NOT VERIFIED
➖ NOT APPLICABLE
```

For:

- valid manifest
- correct start URL
- correct scope
- app icons
- installability
- service worker registration
- service worker updates
- waiting worker handling
- version compatibility
- old cache cleanup
- static asset caching
- navigation caching
- API caching
- user cache isolation
- logout cleanup
- offline fallback
- hard refresh offline
- deep link offline
- offline writes
- sync retries
- idempotency
- conflict resolution
- IndexedDB migrations
- storage quota handling
- push notifications
- notification click handling
- platform fallbacks
- observability
- PWA E2E tests

---

# 198. FRESH INSTALL PASS

Simulate:

```text
clean browser profile
↓
first visit
↓
service worker installation
↓
manifest detection
↓
install app
↓
launch installed app
```

Ask:

- What payload is downloaded?
- Does the service worker install cleanly?
- Does the app render before the worker activates?
- Does the installed app open the correct route?

---

# 199. UPDATE PASS

Critical second-pass scenario:

```text
install and run v1
↓
keep app open
↓
deploy v2
↓
return to app
↓
new service worker detected
↓
update triggered
```

Verify:

- when v2 activates
- whether the user is informed
- whether active state is preserved
- whether v1 and v2 assets collide
- whether legacy assets remain accessible during transition

---

# 200. OFFLINE PASS

Simulate:

```text
online session
↓
visit several routes
↓
disconnect network
```

Then test:

- active route
- previously visited route
- unvisited route
- hard refresh
- browser Back
- browser Forward
- form submission
- API data fetching

---

# 201. LOGOUT PASS

Simulate:

```text
User A logs in
↓
uses app
↓
private responses cached
↓
User A logs out
↓
disconnect network
```

Ask:

> Is User A data still accessible offline?

Then:

```text
User B logs in
```

Ask:

> Can User B view any cached data from User A?

---

# 202. LONG-OFFLINE PASS

Simulate a user remaining offline for days.

During that time:

- backend contracts change
- database schemas evolve
- new client releases deploy

Upon reconnecting:

- do queued mutations remain valid
- does authentication remain valid
- does local storage migrate cleanly
- does the API accept legacy mutation payloads

---

# 203. STORAGE PRESSURE PASS

Imagine:

- thousands of cached images
- extensive API cache records
- months of continuous usage

Ask:

> What purges obsolete local data?

If unhandled, investigate unbounded cache growth.

---

# 204. BAD NETWORK PASS

Do not test only complete disconnection.

A more challenging condition is:

```text
network technically online
↓
requests stall for 20 seconds
↓
some requests succeed
↓
some timeout
```

Inspect:

- Network First timeouts
- duplicate retry attempts
- UI progress feedback
- partial state rendering

---

# 205. MULTI-TAB PASS

Simulate:

```text
Tab A running legacy client
Tab B opened after update
```

Both may interact concurrently with differing frontend state against the same backend.

Verify compatibility.

---

# 206. SERVICE WORKER FAILURE PASS

Assume the service worker:

- fails to install
- encounters Cache Storage errors
- fails to open IndexedDB
- hits storage quota limits

Ask:

> Does the core web application still function?

---

# 207. SECURITY SECOND PASS

Ask this single question:

> What data could the service worker or local cache serve to the wrong user?

Trace all user-specific cache paths once more.

---

# 208. DATA LOSS SECOND PASS

Ask:

> What user action can appear successful in the UI, but never reach the server?

Specifically check:

- offline mutations
- sync queues
- token expiration
- unhandled validation errors

---

# 209. STALE DATA SECOND PASS

Ask:

> What data can remain stale long enough to cause users to make erroneous decisions?

Particularly:

- permissions
- transaction status
- inventory counts
- account balances
- pricing
- active subscriptions

---

# 210. FINAL QUALITY GATE

Before returning your final response, verify:

- you did not declare a PWA high quality merely because a manifest exists
- service worker lifecycle was rigorously evaluated
- update behavior was audited separately from caching behavior
- mixed-version scenarios were investigated
- logout and account switching were checked
- private API caching was analyzed
- offline writes without idempotency were flagged
- conflict resolution was checked only where offline writes exist
- browser platform capabilities were not asserted as universal without validation
- installability was not declared confirmed solely from source inspection
- service worker generator plugin behavior was checked
- PWA features do not break the base web experience when unsupported
- stale data was evaluated against business semantics
- test scenarios include hard-refresh offline tests
- test scenarios include update tests
- bugs and P4 improvements are segregated
- every serious finding traces a lifecycle or cache execution flow

---

# FINAL RULE

I do not want generic recommendations like:

> Add a manifest, a service worker, an offline fallback page, and push notifications.

That is not a PWA audit.

A real PWA defect looks like this:

```text
User A logs in
↓
service worker caches /api/profile
↓
User A logs out
↓
cache remains
↓
User B logs in
↓
same request URL
↓
cached User A profile returned
```

or:

```text
application v1 open
↓
v2 deployed
↓
v2 service worker activates immediately
↓
old v1 page remains open
↓
v1 page sends message format A
↓
v2 worker expects format B
↓
runtime failure
```

or:

```text
user edits data offline
↓
UI indicates Saved
↓
mutation queued
↓
session expires
↓
network returns
↓
server rejects sync
↓
queue never succeeds
↓
user permanently believes data was saved
```

or:

```text
old HTML cached
↓
new deployment removes old chunks
↓
user opens app
↓
cached HTML requests removed chunk
↓
app cannot start
```

These are the critical failure modes you must hunt down.

Think in terms of:

- lifecycles
- version skew
- cache ownership
- user identity boundaries
- offline/online transitions
- retries
- idempotency
- local persistence
- deployment compatibility

If something was not verified at runtime:

**NOT VERIFIED.**

If a capability depends on an unverified browser engine:

**PLATFORM NOT VERIFIED.**

If there is no concrete failure and it is merely an optimization:

**P4 - IMPROVEMENT.**

It is better to find 6 serious PWA lifecycle or cache defects than to generate 60 generic recommendations.

The objective is a forensically rigorous PWA audit demonstrating that the application can safely:

- be installed
- operate under degraded or absent connectivity
- store local records safely
- synchronize offline mutations
- transition between user accounts
- adopt new versions smoothly
- survive legacy client caches
- maintain backend compatibility
- and never lose or leak user data

分类与标签

编程开发、渐进式网页应用、离线同步、缓存安全、版本更新、前端审计

前往 AI 图片创作