Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-plugin-manifest): add cache busting to icon url #8343

Merged
merged 16 commits into from
Mar 12, 2019

Conversation

github0013
Copy link
Contributor

Browsers cache favicons, and it's hard to update them without a random parameter in the favicon link.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Sep 20, 2018

Instead of a random id which will change on every build. How about instead we use an id derived from the content digest of the icon file which will stay consistent across builds.

@pieh
Copy link
Contributor

pieh commented Sep 25, 2018

Just 2 things:

  • There is conflict right now that need to be resolved
  • This function will be called for each page so we would want to cache cacheId first time we calc it to not read file and generate it everytime

@github0013
Copy link
Contributor Author

Let me know if this works.
b29b46e

@DSchau
Copy link
Contributor

DSchau commented Oct 1, 2018

@github0013 looks like the linter is failing! Easiest way to get these passing is to run yarn lint:js --fix or npm run lint:js -- --fix

@github0013 github0013 requested a review from a team as a code owner October 6, 2018 08:35
@github0013 github0013 requested review from a team October 6, 2018 08:35
@github0013 github0013 requested a review from a team as a code owner October 6, 2018 08:35
@DSchau
Copy link
Contributor

DSchau commented Oct 15, 2018

I'll take a look at this first thing tomorrow; sorry for the delay!

Copy link
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Left two comments/questions!

packages/gatsby-plugin-manifest/src/gatsby-ssr.js Outdated Show resolved Hide resolved
@pieh pieh changed the title add random id to the favicon link feat(gatsby-plugin-manifest): add cache busting to icon url Oct 23, 2018
@wardpeet
Copy link
Contributor

@github0013 any chance you can pursuit this one? 👍 it's a great feature to have.

@wardpeet wardpeet added the status: awaiting author response Additional information has been requested from the author label Jan 10, 2019
@moonmeister
Copy link
Contributor

moonmeister commented Jan 31, 2019

@pieh @jlengstorf @DSchau @github0013 I'd like to get this merged, i and others seem interested in solving this problem. I'm currently seeing a couple outstanding issues on this PR.

  • Tests Are failing
  • Linting Is failing
  • createContentDigest isn't available on the SSR API
  • This PR currently only fixes the favicon. What about the manifest and apple icons?

Tests and linting I can handle.

I see there is discussion above concerning making createContentDigest more widely available, as that has not been done I'm inclined to roll this back to using crypto. Thoughts?

Finally, how do we solve adding the digest to all image references? My inclination is to modify the name of the actual files icon-48x48.{{YourDigestHere}}.png... or can we safely add the query string even in the manifest? If either method is valid, does one or the other have any benefit (simplicity, better cross browser cache busting support, etc)?

Thanks folks!

@wardpeet
Copy link
Contributor

wardpeet commented Jan 31, 2019

@moonmeister thanks, feel free to fix the tests if you like. (unsure if you can edit this PR 😛). Cachebusting is fine with querystrings. There is no real benefit about any of them. The downside to querystring busting is that some CDN providers give you the option to omit the querystring as part of the cachekey. Perhaps it's a good idea to do add an option to create a filename 🙊 . [name].[hash].[ext]

I can take care of the utils part

@moonmeister
Copy link
Contributor

@wardpeet I was able to pull the branch just fine, haven't tried pushing yet but guessing it'll work. Yeah, this probably needs to be behind a flag anyway (even if it's on by default), I can have options for [none, query, name] and the code changes how it does cache busting accordingly. This shouldn't be too hard and I have time. If you get the utils done before me then awesome, otherwise I'll just use an internal util in commons and this can be migrated later once the Gatsby util is available.

@moonmeister
Copy link
Contributor

moonmeister commented Jan 31, 2019

Looks like I have some rebasing and might need to revert my move to async/await to be node 6 compatible. And then I need to write tests.

@pieh
Copy link
Contributor

pieh commented Jan 31, 2019

@moonmeister async/await is fine - we run babel on source files when packaging for release so resulting code will be node6 compatible

@moonmeister moonmeister removed the status: awaiting author response Additional information has been requested from the author label Feb 1, 2019
@moonmeister
Copy link
Contributor

@pieh All ready for review and merge!

@moonmeister
Copy link
Contributor

moonmeister commented Feb 2, 2019

Should be good now @pieh

@wardpeet wardpeet added the status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response label Feb 15, 2019
@wardpeet wardpeet self-assigned this Mar 12, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me, I fixed merge conflicts and cleaned it up a little bit.

Thank you for your patience! 🙏

@wardpeet wardpeet merged commit 5f656f8 into gatsbyjs:master Mar 12, 2019
@gatsbot
Copy link

gatsbot bot commented Mar 12, 2019

Holy buckets, @github0013 — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants