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

Fix: Check last modified of resource using helix admin APIs #11

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

Conversation

absarasw
Copy link
Collaborator

@absarasw absarasw commented Sep 21, 2023

Description

This is a fix for ticket SCRNS-3497
There seems to be an issue with the Cloudflare CDN. The last-modified in the franklin URLs are correct but incorrect in cloudflare CDN urls. Since we use custom domains from cloudflare, it's better to check helix admin APIs for the last modified values.

$ curl -si https://main--sodexo--hlxscreens.hlx.page/scripts/delayed.js --compressed | fgrep last-modified
last-modified: Tue, 01 Aug 2023 05:48:18 GMT
$ curl -si https://main--sodexo--hlxscreens.hlx.live/scripts/delayed.js --compressed | fgrep last-modified
last-modified: Tue, 01 Aug 2023 05:48:18 GMT
$ curl -si https://sodexo.aem-screens.net/scripts/delayed.js | fgrep last-modified
last-modified: Tue, 05 Sep 2023 12:21:29 GMT

We can use helix admin APIs whichever give 200 status code to get the last modified.

https://admin.hlx.page/code/hlxscreens/sodexo/main/scripts/delayed.js
Or
https://admin.hlx.page/live/hlxscreens/sodexo/main/scripts/delayed.js

Related Issue

SCRNS-3497

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

const entry = { path: entryPath };

let date = await HelixAdminUtil.getLastModified(entryPath);
if (date === '') {
Copy link

@habansal habansal Sep 29, 2023

Choose a reason for hiding this comment

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

In what case will the Hlx Admin APIs not give the lastModified, but the CloudFlare CDN will provide?
I mean, do we need this if condition?


static getLastModified = async (path) => {
let lastModified = await HelixAdminUtil.getLastModifiedFromAdminAPIs(path, 'code');
if (!lastModified && lastModified === '') {

Choose a reason for hiding this comment

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

should it be || ?

static helixAdminUrl = 'https://admin.hlx.page';

static getLastModified = async (path) => {
let lastModified = await HelixAdminUtil.getLastModifiedFromAdminAPIs(path, 'code');

Choose a reason for hiding this comment

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

Why do we need to check lastModified from .page url?
Shouldn't we check from just .live url?

@@ -148,6 +149,9 @@ export default class GenerateScreensOfflineResources {
lastModified: new Date(lastModified)
};

const hierarchy = PathUtils.getParentHierarchy(manifestData[i].path);
channelEntry.hierarchy = hierarchy;

Choose a reason for hiding this comment

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

is it related to this change?
What's the use of this?

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.

2 participants