restezconnectes / send-pdf-for-contact-form-7

Send the PDF for Contact Form 7 plugin will allow you to recover the data yourself via your form to insert them into a PDF built and prepared by you.
https://restezconnectes.fr/tutoriel-wordpress-lextension-send-pdf-for-contact-form-7/
GNU General Public License v3.0
15 stars 17 forks source link

HTTP-Header "Cache-Control:no-store, no-cache, must-revalidate" #2

Closed Hermsi1337 closed 5 years ago

Hermsi1337 commented 6 years ago

Hey m8,

as soon as I activate your plugin "Send PDF for Contact Form 7" it prevents my Varnish or W3 Total Cache from caching. I investigated it further and found out, that somehow your plugin adds no-cache header to http-response.

Could you tell me why this is the case and how to prevent this? Otherwise I won't get my Varnish working properly.^^

Thank you!

HTTP-Header without plugin:

HTTP/1.1 200 OK
Date: Mon, 20 Nov 2017 08:35:55 GMT
Server: Apache
Link: <http://example.com/wp-json/>; rel="https://api.w.org/"
Upgrade: h2,h2c
Connection: Upgrade, Keep-Alive
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 18339
Keep-Alive: timeout=5, max=100
Content-Type: text/html; charset=UTF-8

HTTP-Header with plugin:

HTTP/1.1 200 OK
Date: Mon, 20 Nov 2017 08:34:56 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Link: <http://example.com/wp-json/>; rel="https://api.w.org/"
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 18339
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

How to reproduce: Simply set up a default WordPress with "Send PDF for Contact Form 7" plugin and load frontend.

ghost commented 6 years ago

Just a guess but this plugin uses PHP sessions so that might be the cause.

Otherwise, these are the only two places I can see that modify headers within the plugin:

https://github.com/Florent73/send-pdf-for-contact-form-7/blob/f4d35e7fc42e9e3b80a34237e0e610eeac98c63f/classes/send-pdf.php#L39

The first has a conditional so should only happen on ?csv=1 (exporting csv?)

https://github.com/Florent73/send-pdf-for-contact-form-7/blob/f4d35e7fc42e9e3b80a34237e0e610eeac98c63f/classes/send-pdf.php#L88

The second should only happen when exporting settings.