Dear Mr Debik,
Thank you for the quick answer. I have added this code to a demo website but nothing changed.
Something happens to the server that creates malfunctions.
I had a scheduled backup task to a google drive account every Sunday at 3am. It matches with the fact that every Sunday (and so on) server behaves strangely.
Slow browsing, very slow checkout completion (30 secs!!!) So I deactivated this scheduled task hoping this will fix the problem (I have also acronis backup activated but I wanted a whole backup in an another location).
I'm attaching a video showing the problem. As you can see, it is a really basic woocommerce website. Page loading isn't too slow (2-3 secs) but order complete proccess is very slow (30 secs!).
After restarting (I will restart server before Monday morning cause customers will be complaining) the page loading is being reduced to 1 second. It is normal cause it is a very basic woocommerce shop. Also, order completion (after pressing the complete order button) lasts about 5 seconds!
@netart.gr
First of all, the code should not be added to a demo website in order to notice the effect of the code : add it to the production site.
However, as a fan of Nginx, I would recommend to use Nginx as a proxy in order to keep some bots and bad traffic away - that is always better than using the .htaccess file that operates on the Apache web server level, for many reasons and I will mention two of them :
1 - Apache is resource heavy : it uses a lot of memory and other resources, whereas Nginx is fast and not resource heavy at all
2 - Nginx as a proxy is "in front" of Apache : any bad traffic is best to be stopped before it reaches Apache
Second, when reading your posts I already assumed that it might be related to scheduled backups........ and you confirm that to some extent in your last post.
I am not sure whether you make a server-wide backup or a subscription/domain based backup.
I am assuming that you have a server-wide backup scheduled ......... which type of backup can take a lot of resources and a lot of time.
I am not certain, but I can also assume to some degree that you have an incremental backup.
In essence, you should first try to get your backups well structured by
3 - using full backups : do not use incremental backups, this will use a lot of disk or storage space and also a lot of resources
4 - using subscription based backups : make subscription based backups on a regular basis and 1 server-wide backup per month - that is really enough!
5 - using local storage : Google Drive can be very slow and very unsafe (read: disconnection will cause your backup to be stopped or even to be broken)
6 - using local storage for high-frequent backups
7 - using remote storage for low-frequent backups, if and only if those backups are relatively small in size
8 - use FTPS (not SFTP) to transport local storage files to remote storage : fast and safe, since the connection will almost never time-out!
I am pretty sure that you will not have and/or will have considerably less performance issues when executing steps 3 to 8.
If you still encounter issues, then it is time to have a look at the traffic and/or at the IPs banned by Fail2Ban ...... but that is another story.
I hope that the above helps ...... and awaiting your news!
Kind regards....