question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removed pages still accessible

See original GitHub issue

Hey, when I un-publish a blog post and build+deploy, the old URLs still are accessible. I assume the files still exist in Cloudfront. @dphang is this something you are aware of / is this supported by this framework?

Describe the bug

  • Un-published URLs are still accessible

Actual behavior

  • Can visit the page

Expected behavior

  • Page gives a 404

Steps to reproduce

  • Deploy a page and visit the URL
  • Un-publish the page
  • Redeploy
  • Refresh the URL and it will still be available

Versions

  • OS/Environment: Deployed from Alpine linux, dev machine is MacOS Big Sur
  • @sls-next/serverless-component version: 1.19.0-alpha.3
  • Next.js version: 9.5.5

Additional context

  • This is a SSG page (getStaticPaths + getStaticProps)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
dphangcommented, Jun 11, 2021

Yes, I think for Lambda@Edge should do it, even though it takes 1-2 minutes longer to deploy (possibly) it will avoid any issues with old cached pages. I’ll add it to the roadmap. You can just set invalidation paths to empty and invalidate yourself using AWS SDK. Here is example how you can poll for the distribution to be ready:

async function checkCloudFrontDistributionReady(
  distributionId: string,
  waitDuration: number,
  pollInterval: number
): Promise<boolean> {
  const startDate = new Date();
  const startTime = startDate.getTime();
  const waitDurationMillis = waitDuration * 1000;

  const cloudfront = new AWS.CloudFront();

  while (new Date().getTime() - startTime < waitDurationMillis) {
    const result = await cloudfront
      .getDistribution({ Id: distributionId })
      .promise();

    if (result.Distribution?.Status === "Deployed") {
      return true;
    }

    console.info(
      `Distribution ${distributionId} is not yet ready. Retrying in ${pollInterval} seconds.`
    );
    await new Promise((r) => setTimeout(r, pollInterval * 1000));
  }

  return false;
}
0reactions
kentobentocommented, Jun 12, 2021

@dphang Great, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

If a page has already been removed on a site, why does it still ...
First, deleted items may be cached by Google. Second, deleted items may be included in Google's search results if they are relevant to...
Read more >
What to Do When Google Still Shows Old Website Pages in a ...
Temporarily hide page from search results and remove from cache : Hides the page from Google search results for about 90 days, and...
Read more >
How to Remove Web Pages Without Damaging Your Search ...
If you need to remove pages on your site, consider if those pages should still be accessible to visitors that access the site....
Read more >
Site content still accessible after site deleted - WordPress.com
IMPORTANT NOTE: Deleting public blogs and/or blog content from them does not remove indexed content from the SERPs (search engine page ...
Read more >
Removing Pages that Incorrectly Appear in Google Search ...
If a page still appears in search results after you do this, you can send a request to Google to remove the page....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found