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

[.cache] Deleted file still shown in gatsby posts #2410

Closed
nodox opened this issue Oct 10, 2017 · 34 comments
Closed

[.cache] Deleted file still shown in gatsby posts #2410

nodox opened this issue Oct 10, 2017 · 34 comments

Comments

@nodox
Copy link
Contributor

@nodox nodox commented Oct 10, 2017

I deleted a folder full of markdown in my src/pages directory but when I went to view my site (in dev) the folder was still being referenced. When I did a build the pages were still being referenced.

I did a grep search but nothing was found. I started wondering if some data was being save locally and I was correct. The .cache folder still had .json referencing the missing files as well as some file that I had updated to fix a typo (and the typo was still showing in development mode).

The fix was to delete the .cache folder. The real problem however is that the updates to the filesystem are not shown in gatsby in realtime which can cause discrepancies. What exactly can you tell us about this interesting bug?

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Oct 10, 2017

Could you test if deleting a file works?

Perhaps this code here doesn't work when a folder is deleted not a file?

watcher.on(`unlink`, path => {

@nodox

This comment has been minimized.

Copy link
Contributor Author

@nodox nodox commented Nov 7, 2017

Still looking into this. Not stale!

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Nov 7, 2017

Did this PR fix things for you? #2546

@misscs

This comment has been minimized.

Copy link

@misscs misscs commented Dec 20, 2017

Also having a similar issue. I modified my json file in project but everytime I build it is referencing stale data. I even tried to delete the .cache/json folder to no avail. Is there a way to clear the cache?

@misscs

This comment has been minimized.

Copy link

@misscs misscs commented Dec 20, 2017

Updated to latest version 👍

@johnrlive

This comment has been minimized.

Copy link

@johnrlive johnrlive commented Feb 1, 2018

To delete your .cache folder just, cd into your project folder and run this in shell:

rm -r ./.cache/*

To rebuild cache just run
gatsby develop or gatsby build

@ryantuck

This comment has been minimized.

Copy link

@ryantuck ryantuck commented Feb 16, 2018

seems like it would help to have this as an arg to pass in, kind of like how docker does it:

gatsby develop --no-cache
@MaxDesiatov

This comment has been minimized.

Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Feb 28, 2018

It could also be helpful to have a gatsby clean command that cleans up the cache and whatever other cleanup is needed. Having this as a separate command would make it more discoverable through gatsby help

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Feb 28, 2018

Creating then deleting caches makes the cache (more than) useless — instead — we need everyone to pitch in helping identify when and where our cache can get invalid. Our cache is already very good and can be perfect. We've merged ~10 PRs over the past 4-5 months fixing up edge cases in handling data in the cache e.g. this recent one #4209

This particular issue was fixed a while ago actually so closing it now.

A general plea — if you ever run across a situation where you think the cache is at fault — please spend a bit of time verifying this it is a cache problem by verifying the problem and then create an issue with how to reproduce the problem, preferably with a sample site I or others could look at.

Caches are amazing and provide incredible speedups and improvements to the DX. Totally understand how annoying a cache is though if you don't feel you can trust it — but I've spent 100s of hours already on the cache and am perfectly willing to spend that much more to make it perfect. But need people's help to identify bugs so they can get fixed.

@MaxDesiatov

This comment has been minimized.

Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Feb 28, 2018

not having an official way to clean the cache until it's working well doesn't help the issue

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Feb 28, 2018

An official way to clear the cache is a strong indication that the project doesn't care about making the cache good which is absolutely not the case. You should never clear the cache. Again, if you ever feel the need to clear the cache, please file an issue.

@timojaask

This comment has been minimized.

Copy link

@timojaask timojaask commented Mar 24, 2018

I'd love a way to reset the cache right now because I just switched one JPEG file for another with the same name, but for whatever reason, Gatsby doesn't see that the file has changed, and keeps showing the old image. It's driving me nuts because I can't figure out how to make it re-read the updated image file.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Mar 24, 2018

@timojaask where is the jpeg image being used? Is it referenced from a markdown file or are you querying it with graphql and ImageSharp?

@timojaask

This comment has been minimized.

Copy link

@timojaask timojaask commented Mar 24, 2018

@KyleAMathews I've got a graphql query with a lot of images, below is a snippet. So I changed the helsinki-basbas5.jpeg image from one to another with the same name.

export const query = graphql`
  query ArticleImages {
    basbas4: imageSharp(id: {regex: "/helsinki-basbas4/" }) {
      sizes(maxWidth: 700, maxHeight: 525, cropFocus: CENTER) {
        ...GatsbyImageSharpSizes
      }
    },
    basbas5: imageSharp(id: {regex: "/helsinki-basbas5/" }) {
      sizes(maxWidth: 700, maxHeight: 525, cropFocus: CENTER) {
        ...GatsbyImageSharpSizes
      }
    },
  }
`;

I noticed that if I change anything in the basbas5 query, it will show the updated image. For example, if I change cropFocus to NORTH, it works. If I change it back to CENTER, it will show the old image again.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Mar 24, 2018

Huh, that's odd. Lemme look into that real quick.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Mar 25, 2018

I didn't make it far with my investigation but this is definitely a bug — we shouldn't be caching any query results if the underlying data changes in some ways. We normally don't I believe so not entirely sure what's happening. I'd appreciate more people investigating.

@m-allanson m-allanson reopened this Mar 26, 2018
@DanceParty

This comment has been minimized.

Copy link

@DanceParty DanceParty commented May 10, 2018

Yes, I am storing markdown files, then deleting them, however the blog post rendered from the markdown file still persists on the webpage. Deleting .cache fixes this.

@filipetedim

This comment has been minimized.

Copy link

@filipetedim filipetedim commented Jun 22, 2018

@KyleAMathews I too found the same issue with the images as @timojaask . In my case (fetching from Wordpress API), if I change an image on there, it seems the GraphQL isn't picking that up and still uses the old one, in both development and production (I suspect cache) as I build and deploy with aws cli. I have to manually go inside the GraphQL query, change something as to force it to re-do the query, and then it works.

Am I doing something wrong or is that just plan weird? The same happens with local images.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Jun 28, 2018

@filipetedim are you restarting gatsby develop? Gatsby doesn't know when you change data in WordPress so you need to trigger refetching data from there (which currently means restarting the develop server).

@filipetedim

This comment has been minimized.

Copy link

@filipetedim filipetedim commented Jun 29, 2018

@KyleAMathews yep. Restarting develop and build too. It just doesn't pick it up unless I manually change something in the query. What I've done is every time this happens, I change the "quality" in the query to 99, then back to 100, then it successfully pulled it.

@alexandresgf

This comment has been minimized.

Copy link

@alexandresgf alexandresgf commented Jul 2, 2018

Same issue here. Trying to do another query using gatsby-source-strapi plugin, and neither the new fields that I created on Strapi, appeared. I already erased the .cache folder, browser cache, and whatever related to it, and nothing happens. The fields that I created aren't appearing.

Error:

TypeError: Cannot read property 'id' of null

Query:

{
  strapiLandingpage(Landing_Owner: {eq: "RemeCoin"}) {
    id
  }
}

The new field is Landing_Owner, and the return:

{
  "data": {
    "strapiLandingpage": null
  }
}

And, the data was previously created in Strapi database.

Someone could help?

Thanks!

@timojaask

This comment has been minimized.

Copy link

@timojaask timojaask commented Jul 6, 2018

@alexandresgf One simple way to make sure the cache is fresh is to rm -rf the entire project and re-clone it from git 😉 Make sure to push all changes before deleting! Works every time!

@kakadiadarpan

This comment has been minimized.

Copy link
Contributor

@kakadiadarpan kakadiadarpan commented Sep 27, 2018

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub issues, we have to clean some of the old issues as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Gatsby version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@penumbra1

This comment has been minimized.

Copy link

@penumbra1 penumbra1 commented Oct 1, 2018

Faced this issue today: swapped one png for another with the same name. SVG traces the new image, but the old one shows up, clipped to the size of the new one. Removing the cache didn't help, but changing the image name did.
chaika

@eivindflobak

This comment has been minimized.

Copy link

@eivindflobak eivindflobak commented Oct 7, 2018

I had the same problem as @timojaask. I am using the latest version of GatsbyJS. Resolved the issue by adding a suffix to my jpeg filename.

@ChristianTucker

This comment has been minimized.

Copy link

@ChristianTucker ChristianTucker commented Nov 1, 2018

Having the same problem using source plugins, I have to delete the .cache folder after adding or removing any nodes for them to show up correctly.

@gatsbot

This comment has been minimized.

Copy link

@gatsbot gatsbot bot commented Nov 16, 2018

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

@gatsbot gatsbot bot closed this Nov 16, 2018
@mukul-rathi

This comment has been minimized.

Copy link

@mukul-rathi mukul-rathi commented Jan 27, 2019

Have a similar problem with svg files - I get the "info changed file at ...../file.svg but the actual webpage doesn't refresh - I have to stop gatsby develop and manually clear the .cache folder.

@DanielRuf DanielRuf reopened this Jan 27, 2019
@gatsbot

This comment has been minimized.

Copy link

@gatsbot gatsbot bot commented Feb 7, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this Feb 7, 2019
@DanielRuf

This comment has been minimized.

Copy link
Member

@DanielRuf DanielRuf commented Feb 7, 2019

It’s been 30 days since
commented 11 days ago

Wait what?

@m-allanson

This comment has been minimized.

Copy link
Member

@m-allanson m-allanson commented Feb 7, 2019

Well... that's not right.

@m-allanson m-allanson reopened this Feb 7, 2019
@m-allanson m-allanson added not stale and removed stale? labels Feb 7, 2019
@DanielRuf

This comment has been minimized.

Copy link
Member

@DanielRuf DanielRuf commented Feb 7, 2019

Sounds like some cachebusting might be the solution / workaround in general (hashes in generated file names and references).

@wardpeet

This comment has been minimized.

Copy link
Member

@wardpeet wardpeet commented Aug 30, 2019

I'm closing this issue, we fixed the problem described in this issue. When removing a md file, the listing gets removed but the html will still be accessible, which is described by #10844.

If it's still an issue please open up a new issue.

@wardpeet wardpeet closed this Aug 30, 2019
@remi2j

This comment has been minimized.

Copy link

@remi2j remi2j commented Jan 18, 2020

I replaced an image with another that had the same name. Gatbsy kept showing the old one, even after removing the cache. I had to rename my image to make the change happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.