Netlify-cms: Media library images become 404 after a while

Created on 9 Nov 2017  路  9Comments  路  Source: netlify/netlify-cms

- Do you want to request a feature or report a bug?

bug

- What is the current behavior?

If left open a while, all of the images in the media library show as broken images. This may only affect private repos, and seems linked to token expiration.

- If the current behavior is a bug, please provide the steps to reproduce.

  • Open the media library with content in a private GitHub repo
  • Leave page open in the background for a few minutes

- What is the expected behavior?

Images should not show as broken (404)

- Please mention your CMS, node.js, and operating system version.

CMS 0.7.0

media-library bug

Most helpful comment

It looks like GitHub raw content URLs are returned with Cache-Control: max-age=300 which means they will stay in the browser cache for at most 300 seconds (then probably the browser tries to load them with an expired token).

image

We should be able to re-use the code from the GraphQL API fix here to handle this.

The GraphQL fix is in the master branch if you're willing to give it a go by adding use_graphql: true to your backend config.

All 9 comments

Regardless of the token issue, the media library shouldn't be reloading images at any point in a session, we need to ensure the call for media in the GitHub backend only occurs once and that the original set is returned in subsequent calls.

Still experiencing this with private repos in 1.0.3. Is a fix still in the works? Willing to help out

The fix for this is going to be #946 - that will introduce thumbnail creation on image upload, and the thumbnail will be committed as metadata, at which point we can begin pulling thumbnails through the API instead of by URL.

@owenhoskins started work on that effort but got busy, maybe you can reach out and see about helping move it forward?

Any updates on this? Having the same issue :(

I see this issue also after I've just logged in. Then only the newly uploaded images are visible.

We have a lot of users of NetlifyCMS and I recommend all of them to use private GitHub repos since it's not very wise to show all the changes to the public including blog posts that are not published yet.

I guess it is because of token expiration. I could imagine that - as @erquhart describes - the token expires if the CMS is left open for a few minutes and then doesn't recover from this state even after a new login.

Workaround: It seems I can get the images back with a full browser refresh.

It looks like GitHub raw content URLs are returned with Cache-Control: max-age=300 which means they will stay in the browser cache for at most 300 seconds (then probably the browser tries to load them with an expired token).

image

We should be able to re-use the code from the GraphQL API fix here to handle this.

The GraphQL fix is in the master branch if you're willing to give it a go by adding use_graphql: true to your backend config.

This issue can be reproduced faster when disabling cache in developer tools:
image

@erquhart we are currently experiencing this issue with a netlify.com cms linked to a private github repo. I see this issue has been closed. Was it fixed or has it been closed because its been merged with https://github.com/netlify/netlify-cms/issues/946 ?

@roganflitton this was fixed in #2817 - can you confirm that you're running 2.10.0 or greater?

Was this page helpful?
0 / 5 - 0 ratings