Turn your website into an installable PWA with offline mode

Convert an existing website into a Progressive Web App: a manifest with icons, a service worker with per-resource caching strategies, an offline page, safe updates and tests. Designed for ChatGPT, Claude, Gemini and Microsoft Copilot. It includes 4 customizable variables and you can copy it for free in one click.

Intermediate · Code · Pending editorial review

Prompt

Act as a web developer who specializes in Progressive Web Apps, service workers and caching strategies.

Context:
- Website or app: {{website}}
- Stack and hosting: {{stack}}
- Offline capability: {{offline_level}}
- Priorities: {{priorities}}

If the site has private areas, personal data or frequently changing content, ask me how they are handled before deciding what gets cached.

Deliverables:
1. The web app manifest: name, short name, colors, display, start_url, scope and icons (192 and 512 px, plus a maskable version), with the tags to add to the HTML.
2. The service worker with one strategy per resource type, explained in a table: precache the app shell, stale-while-revalidate for CSS, JS and images, network-first with a timeout for HTML, and network-only for authenticated API calls.
3. The offline page and how it is served when the network fails.
4. Cache versioning, cleanup of old caches in the activate event and an update flow that tells users a new version is available instead of reloading on them.
5. The service worker registration code and a Workbox alternative if it suits {{stack}} better.
6. Known iOS and Safari limitations I should check, noting that they are worth verifying against current documentation.
7. How to test it: the DevTools Application panel, offline simulation, an installability audit and concrete test cases.

Constraints:
- The site must be served over HTTPS; remind me if the hosting does not guarantee it.
- Do not cache responses containing personal or session data.
- Do not add push notifications or background sync unless my priorities ask for them.
- Mark colors, names and icons I have not given you with [FILL IN].

Output format: strategy table, one code block per file with its path and a test checklist.

How to use it

  1. Describe the site, which parts must work offline and where it is hosted. 2. Add the files, deploy to an HTTPS staging environment and check the DevTools Application panel. 3. On a real phone, test installing it, airplane mode and the arrival of a new version.

Usage example

Website: recipe site with search and recipe pages · Stack: static site built with Astro on Netlify · Offline: read recipes already visited · Priorities: installable on Android and fast repeat loads.

Sample output

Caching strategies

ResourceStrategy
Shell (home, offline page, manifest)Precache on install
Recipe pages (HTML)Network first; on failure, cache, then /offline/
CSS, JS, imagesStale-while-revalidate

public/sw.js

const VERSION = 'v1';
const SHELL = `shell-${VERSION}`;
const PAGES = `pages-${VERSION}`;
const ASSETS = `assets-${VERSION}`;
const PRECACHE = ['/', '/offline/', '/manifest.webmanifest']; // [FILL IN: Astro hashed CSS/JS]

self.addEventListener('install', (event) => {
  event.waitUntil(caches.open(SHELL).then((cache) => cache.addAll(PRECACHE)));
});

self.addEventListener('activate', (event) => {
  const current = [SHELL, PAGES, ASSETS];
  event.waitUntil(caches.keys().then((keys) =>
    Promise.all(keys.filter((k) => !current.includes(k)).map((k) => caches.delete(k)))));
});

const store = (name, request, res) => {
  if (res.ok) { const copy = res.clone(); caches.open(name).then((c) => c.put(request, copy)); }
  return res;
};

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  if (request.mode === 'navigate') {
    event.respondWith(fetch(request).then((res) => store(PAGES, request, res))
      .catch(async () => (await caches.match(request)) ?? caches.match('/offline/')));
    return;
  }
  event.respondWith(caches.match(request).then((cached) => {
    const network = fetch(request).then((res) => store(ASSETS, request, res)).catch(() => cached);
    return cached ?? network;
  }));
});

Bumping VERSION makes activate delete old caches. Netlify always serves over HTTPS, which service workers require…

Key facts

Category
Programming & development · Build websites
Output type
Code
Level
Intermediate
Designed for
ChatGPT, Claude, Gemini and Microsoft Copilot
Verified in
Pending editorial verification
Variables
Website or app, Stack and hosting, Offline capability and Priorities
Language
English
Price
Free, no sign-up
Updated
Nov 7, 2026

Frequently asked questions

What does a site need to be installable as a PWA?

At minimum, HTTPS and a manifest with a name, icons and start_url. Each browser has its own criteria; a service worker with an offline response improves the experience and some browsers take it into account.

Why not reload the page automatically when the service worker updates?

Because users may lose what they were doing, such as a half-filled form. It is better to tell them a new version is ready and let them choose when to reload.

What is stale-while-revalidate?

A strategy that serves the cached copy instantly while fetching a fresh version from the network for next time. It is fast and keeps content reasonably up to date.

What is this prompt for?

Convert an existing website into a Progressive Web App: a manifest with icons, a service worker with per-resource caching strategies, an offline page, safe updates and tests.

Which AI tools does it work with?

It is designed for ChatGPT, Claude, Gemini and Microsoft Copilot. We have not verified it in these tools yet, so results may vary between them.

How do I customize the prompt?

Click “Customize” and fill in the variables (Website or app, Stack and hosting, Offline capability and Priorities). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.

Do I need experience to use it?

It is intermediate: it helps to know the topic so you can provide good context and review the result critically.

Is this prompt free?

Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.

Can I trust the AI output?

Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.

Related prompts