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

Add caching and cache-busting to dapp icons #2697

Merged
merged 25 commits into from
Nov 22, 2024
Merged

Add caching and cache-busting to dapp icons #2697

merged 25 commits into from
Nov 22, 2024

Conversation

LXIF
Copy link
Contributor

@LXIF LXIF commented Nov 20, 2024

Updated the location and then imports/loading of the dapp icons to use file hashes and the cacheable filename tag, so their cache-control headers are also set so 1 year but changing the file will reload them immediately.

Added a test that checks whether the header is set correctly (had to add a gzip decoder in the dev dependencies for that)


🟡 Some screens were changed

@LXIF LXIF requested a review from lmuntaner November 20, 2024 17:26
@LXIF LXIF requested a review from a team as a code owner November 20, 2024 17:26
@LXIF
Copy link
Contributor Author

LXIF commented Nov 20, 2024

Will need to change the frontend checks because the logos are now in a different place.

@LXIF
Copy link
Contributor Author

LXIF commented Nov 21, 2024

changed the checks in here but they're also in separate PRs, we should approve and merge the separate PRs before this one

@LXIF
Copy link
Contributor Author

LXIF commented Nov 21, 2024

Added smooth transitions so the lazy-loaded images aren't jarring and everything looks slick. (The 'blinking' is me hitting cmd-r to reload to display the effect)

Screen.Recording.2024-11-21.at.13.58.50.mov

@LXIF
Copy link
Contributor Author

LXIF commented Nov 21, 2024

Ran the update dapps action with the new configuration, all runs well except the PR to main because of merge conflicts with main - this should be temporary though.

Screenshot 2024-11-21 at 14 33 02

https://github.com/dfinity/internet-identity/actions/runs/11954189450/job/33323727838

@LXIF LXIF requested a review from sea-snake November 21, 2024 14:18
Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

I realized I never sent my review, sorry!

@@ -10,7 +10,7 @@ cd "$SCRIPTS_DIR/.."
# The path where we save the list of dapps in II
DAPPS_JSON="$PWD/src/frontend/src/flows/dappsExplorer/dapps.json"
# The path where we save logos in II
II_LOGO_PREFIX="src/frontend/assets/icons"
II_LOGO_PREFIX="src/frontend/assets/src/assets/icons"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this correct? Shouldn't it be frontend/src/assets/icons?

Is this also in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jfc i thought i had corrected that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait it says outdated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I already corrected it. It's also in another PR, here: #2701

@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Internet Identity</title>
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="shortcut icon" href="/src/assets/favicon.ico" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this changing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we can set the cache-control header of the favicon and add a filehash to it so it too is cached. It's another 15kb and in my tests it could take quite a bit of time to load on some refreshes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Noted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to move this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not 100% vital but it's another 15kb that was previously static and is now cached with a hash.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, noted.

import { features } from "$src/features";
const iconFiles = import.meta.glob("../../assets/icons/*", {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment with the absolute path from the root directory? In case we ever move this file, to know where this relative path should be pointing to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

Nice!

Already approving but I added some more comments to maybe add minor changes.

src/internet_identity/tests/integration/http.rs Outdated Show resolved Hide resolved
src/internet_identity/tests/integration/http.rs Outdated Show resolved Hide resolved
@LXIF LXIF added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit 69b89df Nov 22, 2024
67 checks passed
@LXIF LXIF deleted the andri/cache-icons branch November 22, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants