Skip to content

fix(cdn): MERC-9364 Use CDN Original images for webdav - cache control #298

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

christensenep
Copy link

@christensenep christensenep commented Dec 29, 2023

What? Why?

! DO NOT MERGE !

Use CDN Original images for webdav - cache control. Take 2. See bigcommerce/paper#343

If a developer/merchant uses the cdn handlebars helper to inject images from webdav into the theme using e.g.({{cdn "webdav:/img/image.jpg"}}), there is no cache-control header when the image is fetched on the storefront.

Similar to our Image Manager, we should be using the cdn original images (Similar to Jinsoo's PR here MERC-7127)

This PR differs from the previous as it only does this for file suffixes that image manager supports (jpg/jpeg/png/gif). This avoids the issue where the url is changed for e.g. a pdf, and thus creates a broken link.

How was it tested?

Tested locally and in integration, and with unit tests. Have verified that images (png/gif/jpeg/jpg) uploaded to the content directory via webdav can be accessed at their cache-controlled url using the cdn helper (/images/stencil/original/content/<whatever>), while all other file extensions still return the /content/<whatever> path when using the helper.

Behold, the results of outputting some of these urls directly to the DOM:
Screenshot 2024-01-11 at 4 40 25 PM

cc @bigcommerce/storefront-team

@christensenep christensenep changed the title MERC-9364 Use CDN Original images for webdav - cache control fix: MERC-9364 Use CDN Original images for webdav - cache control Dec 29, 2023
@christensenep christensenep force-pushed the MERC-9364 branch 2 times, most recently from 06cc938 to a52423f Compare December 29, 2023 01:02
@christensenep
Copy link
Author

♻️ I have tested this with gifs, jpeg/jpgs and pngs, and verified that the new urls are valid and have cache control headers. I have also verified that other file extensions such as pdfs and, importantly, bmps do not change the url from its current form and are thus still valid. I also verified that bmps do not have the images/stencil/content form of the url available, so I believe this is the correct and exhaustive of extensions we should be doing this for.

@christensenep
Copy link
Author

@bigcommerce/team-merchandising @bigcommerce/team-storefront

jairo-bc
jairo-bc previously approved these changes Jan 15, 2024
@bc-alexsaiannyi bc-alexsaiannyi force-pushed the MERC-9364 branch 2 times, most recently from 82294e2 to 3344da0 Compare March 6, 2025 13:15
@bc-alexsaiannyi bc-alexsaiannyi force-pushed the MERC-9364 branch 2 times, most recently from 8b8ca19 to c9f8d6b Compare March 17, 2025 20:44
@bc-alexsaiannyi bc-alexsaiannyi force-pushed the MERC-9364 branch 3 times, most recently from de37add to 8b2e272 Compare April 14, 2025 10:18
jmwiese
jmwiese previously approved these changes Apr 29, 2025
Copy link
Contributor

@jmwiese jmwiese left a comment

Choose a reason for hiding this comment

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

LGTM

@bc-alexsaiannyi bc-alexsaiannyi changed the title fix: MERC-9364 Use CDN Original images for webdav - cache control [DO NOT CLOSED] fix: MERC-9364 Use CDN Original images for webdav - cache control Apr 30, 2025
@bc-alexsaiannyi bc-alexsaiannyi changed the title [DO NOT CLOSED] fix: MERC-9364 Use CDN Original images for webdav - cache control [DO NOT CLOSE] fix: MERC-9364 Use CDN Original images for webdav - cache control Apr 30, 2025
@bcsnyk
Copy link

bcsnyk commented May 27, 2025

🎉 Snyk checks have passed. No issues have been found so far.

code/snyk check is complete. No issues have been found. (View Details)

@bc-alexsaiannyi bc-alexsaiannyi changed the title [DO NOT CLOSE] fix: MERC-9364 Use CDN Original images for webdav - cache control MERC-9364 Use CDN Original images for webdav - cache control May 27, 2025
@bc-alexsaiannyi bc-alexsaiannyi changed the title MERC-9364 Use CDN Original images for webdav - cache control fix: MERC-9364 Use CDN Original images for webdav - cache control May 27, 2025
@bc-alexsaiannyi bc-alexsaiannyi added the WIP Work in progress label May 27, 2025
@bc-alexsaiannyi bc-alexsaiannyi changed the title fix: MERC-9364 Use CDN Original images for webdav - cache control [ DO NOT MERGE] fix: MERC-9364 Use CDN Original images for webdav - cache control May 27, 2025
@bc-alexsaiannyi bc-alexsaiannyi changed the title [ DO NOT MERGE] fix: MERC-9364 Use CDN Original images for webdav - cache control fix(cdn): MERC-9364 Use CDN Original images for webdav - cache control May 28, 2025
@bc-alexsaiannyi bc-alexsaiannyi force-pushed the MERC-9364 branch 14 times, most recently from f766ffe to 1e15c95 Compare May 28, 2025 13:52
package.json Outdated
@@ -34,7 +34,7 @@
"homepage": "https://github.com/bigcommerce/paper-handlebars",
"dependencies": {
"@bigcommerce/handlebars-v4": "4.7.8",
"chrono-node": "^2.6.5",
"chrono-node": "2.8.0",

Choose a reason for hiding this comment

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

FYI. currently 2.8.1 is broken and temporary downgraded to 2.8.0

Copy link

Choose a reason for hiding this comment

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

Do we need to upgrade this as part of this PR? I am asking because if we need to revert it might not be straightforward PR revert.

Choose a reason for hiding this comment

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

yes, since we have to update storefront-renderer as well based on these changes , it will break it also. I guess since we won't merge it right now, later the version will be updated anyway. And we also have experiment for now, so we should be safe.

Copy link
Member

@rtalvarez rtalvarez May 28, 2025

Choose a reason for hiding this comment

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

i guess im also not following, why do we need the bump? your changes dont look to require this update. maybe im missing something

also i dont see how the experiment would protect you from this version bump (also missing package-lock changes either way ?)

Choose a reason for hiding this comment

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

@rtalvarez, it' was a blocker for running jobs. Most of them were failed due to Error: Cannot find module '../../../../src/common/abstractRefiners' that eventually was cased by bad release of chrono-node dependency. Similar issue can be found here. So I went to Jairo asking him how much it's critical and since we're not going to merge this branch, if we can skip it. My understanding - since we need to update SFR based on paper-handlebars changes, probably dependencies will be reinstalled under the hood with broken version of chrono-node anyway. cc @jairo-bc

Choose a reason for hiding this comment

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

in terms of experiment I only mean that we simply can turn it off, if something is broken and SFR would use original version of handlebars.
package-lock is under gitignore and i don't see it in the project structure as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bc-alexsaiannyi feel free to merge master into your branch, this change is already there

Choose a reason for hiding this comment

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

great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants