Home > other >  NGINX return 410 for deleted CSS and JS files
NGINX return 410 for deleted CSS and JS files

Time:01-25

I have a problem with a plugin I've deleted, apparently the cache on the users browser still send request for some JS and CSS files that are gone, the problem is that this is causing a lot of 404 errors in the logs (in 1 day I generated 4GB of error logs only containing the 404 deleted CSS and JS files).

I was trying to create a setting on NGINX that will send a 410 response to everyone that was trying to access the missing JS and CSS files, the path of the files is the same:

/wp-content/cache/autoptimize/js/autoptimize_single_32ab5663ad75c559c9af68098a1b63e6.js

/wp-content/cache/autoptimize/css/autoptimize_32c1c99d8f7a5a9618074737134c8f9c.css

I tried various location settings I found online for both all files that contains autoptimize_*.css and js and the folder /autoptimize, but it didn't work, it was like this:

location ^~ /autoptimize { return 410; }

What I'm missing?

CodePudding user response:

Try :

location ^~ /wp-content/cache/autoptimize/ { return 410; }
  •  Tags:  
  • Related