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 · 36 comments
Closed

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

nodox opened this issue Oct 10, 2017 · 36 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@nodox
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

nodox commented Nov 7, 2017

Still looking into this. Not stale!

@KyleAMathews
Copy link
Contributor

Did this PR fix things for you? #2546

@misscs
Copy link

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
Copy link

misscs commented Dec 20, 2017

Updated to latest version 👍

@johnrlive
Copy link

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
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@KyleAMathews
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

@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
Copy link

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
Copy link
Contributor

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

@KyleAMathews
Copy link
Contributor

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
Copy link

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
Copy link

@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
Copy link
Contributor

@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
Copy link

@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
Copy link

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
Copy link

@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 kakadiadarpan added the type: question or discussion Issue discussing or asking a question about Gatsby label Sep 27, 2018
@kakadiadarpan
Copy link
Contributor

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 👍

@kakadiadarpan kakadiadarpan added the stale? Issue that may be closed soon due to the original author not responding any more. label Sep 27, 2018
@penumbra1
Copy link

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
Copy link

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
Copy link

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
Copy link

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 as completed Nov 16, 2018
@mukul-rathi
Copy link
Contributor

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
Copy link

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 as completed Feb 7, 2019
@DanielRuf
Copy link
Contributor

It’s been 30 days since
commented 11 days ago

Wait what?

@m-allanson
Copy link
Contributor

Well... that's not right.

@m-allanson m-allanson reopened this Feb 7, 2019
@m-allanson m-allanson added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Feb 7, 2019
@DanielRuf
Copy link
Contributor

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

@wardpeet
Copy link
Contributor

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.

@remidej
Copy link
Contributor

remidej 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.

@bobgravity1
Copy link

bobgravity1 commented Nov 8, 2021

this happens to me all the time with gatsby. really annoying. takes like an hour of just messing around and RANDOMLY it works again.. happening to me right now. deleting cache sometimes helps. deleting node modules. npm install again. really a bunch of stuff... to all the people saying to never delete caches. good luck using gatsby without having to do that 8-9 times each project. i love gatsby but this kind of random unexplained error stuff happens way too often

@bobgravity1
Copy link

bobgravity1 commented Nov 8, 2021

solution this time: copy and paste the text from markdown. copy images. delete it. delete cache. delete node modules. run npm. run build. THEN make a new markdown file and paste it all in

yes... this is why gatsby is ridiculous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests