I have a php website running on a DigitalOcean droplet (nginx server), and I also use Cloudflare. Recently, my website was hit by something that I yet did not understand.. as my CPU usage was usually 1-2% and it went to 100% for a few hours resulting in my server crashing.
My Cloudflare analytics showed an extremely high number of visitors - of which I am sure was not human traffic.
Cloudflare asked to see my nginx error logs and access logs. Following is their reply -
You have 2 caching headers that are going to expire your assets as soon as they get stored at our edge.
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
and
< Expires:> Thu, 19 Nov 1981 08:52:00 GMT.
Because the Expires header is set to sometime in the past, the cache is going to be expired the moment it hits our edge. Then you have your cache-control header basically saying do not store any of the assets at our edge, but you have a caching enabled, so our edge will continue to crawl your site. This can cause what looks like a DoS attack against your origin.
Can someone please tell me how can I set my Expires header and Cache-control header on my Nginx server?
!