Webinoly is just the perfect tool for NGINX experts. Give it a try!
0 votes
228 views
by Rookie
I am using the Generate Press WP theme, which has an option to generate an external stylesheet for dynamic CSS (for the options generated by the customizer). Sometimes I get 502 errors for the generated stylesheet after making a change in the customizer which resolves itself after a few minutes.

It doesn't happen every time I save settings in the customizer, only sometimes.

This is the error message I am getting in the error log when this happens.

2020/12/01 20:44:35 [alert] 43690#43690: *18956 pread() read only 6064 of 6215 from "/var/www/example.com/htdocs/files/generatepress/style.min.css" while sending response to client, client: x.x.x.x, server: example.com, request: "GET /files/generatepress/style.min.css?ver=1606877048 HTTP/2.0", host: "example.com", referrer: "https://example.com/test-page.html"

I think it might be caused by the open_file_cache settings in nginx.conf, but I'm not really sure. Unlike other stylesheets, this one is uploaded to the media folder. I changed my WP media folder to 'files' instead of wp-content/uploads, so the location is:

/var/www/example.com/htdocs/files/generatepress/style.min.css

Could the location where the file is stored have anything to do with this? When I edit other css files this never happens, only with that specific one that gets automatically generated by changing the customizer options.

Any ideas on how to prevent this from happening?
by Rookie
reshown by

Hey, I just wanted to make an update on what I have found.

After more testing I also saw this error happen on the child theme css file after editing it in the Wordpress Theme Editor sometimes. The error shown in browser console is net::ERR_HTTP2_PROTOCOL_ERROR 200 (I thought it was a 502 error with the stylesheet generated by the theme customizer but I could be mistaken).

I was able to reproduce this error by the following procedure:

1. Open site and hard refresh a few times to make sure the file is cached by nginx (Chrome browser hold down shift key while clicking the refresh button).

2. Edit a css file in Wordpress theme editor and then save it.

3. Open an incognito window and load the site. The css file that you edited will not load and you should see an error in the NGINX error log "pread() read only xxxx of yyyy from..."

I commented out these 2 lines in the nginx.conf file and it seems to have solved the problem.

#open_file_cache_valid 3m;
#open_file_cache max=37440 inactive=5m;

I guess I will leave these lines commented out while I'm developing my site and often modifying css files and then restore the options once the site goes live. Unless anyone has a better a suggestion on this?

Please log in or register to answer this question.

Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...