Why do PDFs look like gibberish when using WP Super Cache?
By default, WP Super Cache overrides the correct Content Type (or Mime Type) of our PDF files, which should be “application/pdf”, replacing it with “text/html”. This causes browsers to try rendering the PDF file as an HTML webpage, which doesn’t work.
The solution is to exclude your Invoice pages from being cached by WP Super Cache. To do this:
- Go to WP Super Cache Settings, Advanced tab
- Under “Accepted Filenames & Rejected URIs”, there is a box of strings under “Add here strings (not a filename) that forces a page not to be cached…” Enter your invoices slug here (the default is “sliced_invoice”) and it will prevent this issue from happening. Just add a line like this and Save it:
/sliced_invoice/
Also, WP Super Cache can sometimes interfere with payments processing, so it is recommended you add one more line as long as you are there:
/payment/
The end result should look like this: