1

I tested my angular pwa on Lighthouse and got back the following: enter image description here

I have altered my ngsw-config.json to try to add cacheConfig for the assetGroups, however it seems that is only valid for the dataGroups?

I have also tried editing my htaccess file and adding the following line:

Header set Cache-Control: "max-age=31536000, public"

None of this has worked for me so far.

CodeBroJohn
  • 1,085
  • 8
  • 17
  • 1
    I don't think that this is something you can fix on the client. I believe that on the server, you need to set appropriate Cache-Control headers on the responses. – Will Taylor Apr 09 '19 at 15:55
  • @WillTaylor. What do you mean by "to set appropriate Cache-Control headers on the responses". Is this on the backend? server? – Joseph Dec 22 '19 at 05:14
  • @Joseph yes that is it. It is a header which needs to be set by whatever server is serving your static assets such as html, css, js and images. – Will Taylor Dec 24 '19 at 07:56
  • @Will Taylor. What would be the ideal Cache Control settings? Always set it to 0 and no-cache? – Joseph Dec 24 '19 at 08:48

1 Answers1

0

There is no max-age for assetGroups but you can set max-age for dataGroups like this:

"dataGroups": [
{
  "name": "API Call",
  "urls": ["https://website.com"],
  "cacheConfig": {
    "maxAge": "30m",
    "strategy": "performance",
    "maxSize": 10
  }
}
]

Define this on the same level as assetGroups

cyperpunk
  • 664
  • 7
  • 13