-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Description
In AR we generate a pre-warm file containing references to all our JS and Fonts. Its a bit of a hack but this file is loaded by the iOS app in order to get it to download all of the required assets for offline reading in advance.
https://mobile.guardianapis.com/assets/rendered-items-assets.html
dotcom-rendering/apps-rendering/webpack.config.ts
Lines 219 to 242 in ba40e6b
| new HtmlWebpackPlugin({ | |
| excludeChunks: ['editions'], | |
| meta: { | |
| 'Content-Security-Policy': { | |
| 'http-equiv': 'Content-Security-Policy', | |
| content: `style-src 'sha256-${assetHash( | |
| assetsTemplateCss, | |
| )}';`, | |
| }, | |
| }, | |
| filename: 'rendered-items-assets.html', | |
| template: path.resolve( | |
| __dirname, | |
| 'config/rendered-items-assets-template.html', | |
| ), | |
| minify: true, | |
| templateParameters: { | |
| styles: assetsTemplateCss, | |
| }, | |
| }), | |
| new webpack.ProvidePlugin({ | |
| Buffer: ['buffer', 'Buffer'], | |
| }), | |
| ], |
We'll likely need to generate a similar file for DCAR.
Steps
- Create a template HTML file
- Consume said template HTML file
- Use all DCR fonts in said template file + potentially all AR fonts too
- Use Apps JS bundle (might scrap this - see below)
Issues with current implementation
We noticed that the cache time on https://mobile.guardianapis.com/assets/rendered-items-assets.html is quite long and it doesn't appear to get purged on deployment. This is fine for fonts as their assets path rarely/never changes, but our javascript bundle has a hashed path and changes every time we change our JS.
This means that because our rendered-items-assets.html file is always either in the fastly cache or local cache that it will probably reference an old version of the JS bundle and will be useless as we won't be using that version on articles.