Through a simple configuration, a content author can now enable progressive web app (PWA) features for experiences created in AEM Sites.
This is an advanced feature that requires:
Before using this feature is is recommended that you discuss this with your development team to define the best way to leverage it for your project.
Progressive web apps (PWAs) enable immersive app-like experiences for AEM sites by allowing them to be stored locally on a user’s machine and be accessible offline. A user could browse a site while on-the-go even if losing an internet connection. PWAs allow seamless experiences even if the network is lost or unstable.
Instead of requiring any re-coding of the site, a content author is able to configure PWA properties as an additional tab in the page properties of a site.
With PWA, the user has a local copy of the site, giving an app-like experience even without an internet connection.
Progressive web apps are an evolving technology and support for local app installation and other features depends on which browser you use.
To be able to use PWA features for your site, there are two requirements for your project environment:
These are technical steps that the author will need to coordinate with the development team. These steps are only required once per site.
Core Components release 2.15.0 and later fully support the PWA features of AEM sites. Since AEMaaCS always includes the latest version of the Core Components, you can leverage PWA features out-of-the-box. Your AEMaaCS project automatically fulfills this requirement.
Adobe does not recommend using the PWA features on custom components or components not extended from the Core Components.
The PWA feature generates and uses /content/<sitename>/manifest.webmanifest
files. By default, the dispatcher doesn’t expose such files. To expose these files, the developer must add the following configuration to your site project.
File location: [project directory]/dispatcher/src/conf.dispatcher.d/filters/filters.any >
# Allow webmanifest files
/0102 { /type "allow" /extension "webmanifest" /path "/content/*/manifest" }
Depending on your project you may want to include different types of extensions to the rewrite rules. The webmanifest
extension can be useful to include in the rewrite conditions when you introduced a rule that hides and redirects requests to /content/<projectName>
.
RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg|.webmanifest)$
With the prerequisites met, it is very easy for a content author to enable PWA features to a site. The following is a basic outline of how to do this. Individual options are detailed in section Detailed Options.
Log into AEM.
From the main menu, tap or click Navigation -> Sites.
Select your sites project and tap or click Properties or use the hotkey p
.
Select the Progressive Web App tab and configure the applicable properties. At a minimum you will want to:
Select the option Enable PWA.
Define the Startup URL.
Upload a 512x512 png icon to the DAM and reference that as the icon for the app.
Configure the paths you want the service worker to take offline. Typical paths are:
/content/<sitename>
/content/experiencefragements/<sitename>
/content/dam/<sitename>
/etc/clientlibs/<sitename>
Tap or click Save & Close.
Your site is now configured and you can install it as a local app.
Now that you have configured your site to support PWA, you can experience it for yourself.
The following section provides more detail on the options available when configuring your site for PWA.
These settings allow your site behave like a native app by making it installable on the visitor’s home screen and available offline.
These settings make parts of this site available offline and available locally on your visitor’s device. This allows controlling the cache of the web app to optimize network requests and support offline experiences.
Your developer team likely has valuable input regarding how your offline configuration should be set up.
Not all PWA features are available for AEM Sites. These are a few notable limitations.
Adobe also makes the following recommendations when you implement PWA.
Adobe advises you to limit the number of pages to pre-cache.
Client libraries are delivered with the addition of a cache selector observing the following pattern lc-<checksumHash>-lc
. Every time one of the files (and dependencies) that compose a library change, this selector changes. If you listed a client-library to be pre-cached by the service-worker and you want to refer to a new version, you manually retrieve and update the entry. As a result, we advise you to configure your site to be a PWA after the project scripts and stylesheets are stabilized.
The Image Component of the AEM Core Components determines one the front end the best rendition to fetch. This mechanism also includes a timestamp that corresponds to the last modified time of that resource. This mechanism complicates the configuration of the PWA pre-cache.
When configuring the pre-cache, the user needs to list all the path variations that can be fetched. These variations are composed of parameters like quality and width. It is strongly advised to reduce the number of these variations to a maximum of three - small, medium, large. You can do that via the content-policy dialog of the Image Component.
If not configured carefully, memory and network consumption can severely impact the performance of your PWA. Also if you intend to precache, say, 50 images, and have 3 widths per image, the user maintaining the site will have to maintain a list of up to 150 entries in the PWA pre-cache section of the page properties.
Adobe also advises you to configure your site to be a PWA after the project use of images has stabilized.