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

Lot of 404 on generated JS / CSS Files #43

Closed
manuhook opened this issue Nov 12, 2016 · 14 comments
Closed

Lot of 404 on generated JS / CSS Files #43

manuhook opened this issue Nov 12, 2016 · 14 comments

Comments

@manuhook
Copy link

manuhook commented Nov 12, 2016

Hi Maxime,

I moved from apache to nginx,
Everything is working fine when i'm browsing the website on my side (and on different devices) everything is correctly loaded but on my error log i have a lot of 404 errors on js and css generated by wp-rocket in the /wp-content/cache/min/1/.
No 404 errors on other files (videos, images).
Thoses 404 errors are generated by other visits. The problem is not for everyone cause 95% of the request on the access log are fine.

I can't figure out where thoses errors come from :(

Can it be the browser cache of the client ? Do you have an idea how i can fix that ? I was having no problem on apache.

Thank you very much !

@maximejobin
Copy link
Collaborator

Hello,

You said you did not have this problem with Apache. So my question is: Did this start when you started to use WP-Rocket or if it started when you started to use Rocket-Nginx ? If you don't know, simply disable Rocket-Nginx and see if you still have the problem.

Without having the full details, I would say the problem comes from browser cache. The reason could be that the HTML page is cached (with links to CSS and JS). Then, the HTML page is updated with new CSS and JS. But for some reason, when the visitor asks for the page, it uses the old html page (instead of getting the updated one) and tries to get the old CSS and JS... and that's why you have 404.

@maximejobin
Copy link
Collaborator

I do think you found something interesting and I found a great article about caching. I link it here for future reference: https://kjaer.io/quick-cache-this/.

That said, I think you are right and that Rocket-Nginx could be better and not trigger these 404 error. I'll do some testing and try to release a better version ASAP.

In the meantime, I encourage you to comment line (with # in front of the line):

Then, reload the configuration ( service nginx reload) and let me know if it solved the problem. It should. Then, I'll adjust the cache to make sure it does not cache HTML when it's not fresh anymore (which is your problem now).

@manuhook
Copy link
Author

manuhook commented Nov 15, 2016

Thanks a lot for your answers Maxime, much appreciated :)

I'm still investigating on my side,

My theory for the moment is this one :

75% of my users are on mobile.
Sometines, on a mobile browser when you leave a webpage to go to another tab or app, and the you come back on the page you were, there is sometimes a kind of refresh, I don't know if the all page is really refreshed (html + content) or just the content is called one more time... if it's just the content, it can explain why it can't find the css/js if the cache was cleaned during the user was away.

But i'm still looking to reproduce the problem and still no luck :P

I'm going to try your last suggestion anyway :)

(if you need me to provide you log, or conf file i'm using, don't hesitate to ask me !)

@maximejobin
Copy link
Collaborator

Even with a refresh, the web server should send the right file and not assume it hasn't change. I'm pretty confident the problem was caused by the configuration. Checking my logs, I also have some 404. Not a lot... but it has to be addressed.

Thanks again for your time! And let me know if your changes solved the problem. Then, I'll be looking for a fix.

@manuhook
Copy link
Author

Ok, the modification is done ! I will let you know asap if there is some changes.
Thank again ! 👍

@manuhook
Copy link
Author

Hi Maxime,

I can't see any ameliorations, i still have a lot of 404 on the .js & .css minified only. Do you have another idea ?

Thank you !

@maximejobin
Copy link
Collaborator

It might be because the HTML file was cached for a long period. Can you see if you have:

  1. The same amount of 404.
  2. Less than you had.

It might take some time to clear the old cached items.

Also, if it's the same amount, I will suggest this: remove Rocket-Nginx from your configuration for some time and see what happens. Then, you can reactivate it.

Honestly, I did not have time to do much testing on this. Holidays is where I'll have time.

@manuhook
Copy link
Author

Ok, Thank you for your fast anwser, it's hard to say cause the traffic is now more important, i will say i have the same amount of errors.

I'm going to try to remove Rocket-Nginx in a week and i will let you know if i have somme change.

Thanks again,

@nurul-umbhiya
Copy link

Hi,
I'm also getting lots of 404 errors after I enabled/installed Rocket-Nginx.
https://www.diigo.com/item/image/5kn12/kb1h
Now I've disabled it. Waiting for this problem to fix. I'll enable this configuration after this problem is fixed.
Regrads,

@manuhook
Copy link
Author

Hi Maxime,
I'm trying to add expires -1, and expires 0 for gzip/html files to see if I get something better.
Don't hesitate to tell me if you think this test is useless :)

@maximejobin
Copy link
Collaborator

This is totally what I wanted to suggest for now. Then, if it solves the issue, we'll know the lines I told you to comment were problematic. As the cache was for 30 days, you can't expect perfect result for the next 30 days (some old visitors may still have the cached version).

Then, I will explore the "cache the page BUT also check with the server if a new version is available". That is faster than simply never caching the page with expires -1;.

@manuhook
Copy link
Author

Hi Maxime,
Some news about the issue :
No luck with expires -1 and expires 0.
With that you get respectively the header cache-control: no-cache or cache-control: max-age=0 + the expires header
Even with those header, some browser are still caching the page and you get a 304 when you revisit it.
I've removed expires -1 and added this header cache-control: no-cache, no-store, must-revalidate
No more 404 on js/css, and always 200 instead of 304 when accessing the html page.

@maximejobin
Copy link
Collaborator

Thank you very much for your output, I will consider the information you gave me for version 2.0.

@maximejobin maximejobin added this to the 2.0 milestone Apr 9, 2017
@maximejobin
Copy link
Collaborator

Fixed in 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants