-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Add temporary PDF cache #1556
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## development #1556 +/- ##
===============================================
+ Coverage 76.07% 76.12% +0.04%
===============================================
Files 248 250 +2
Lines 12993 13127 +134
Branches 370 370
===============================================
+ Hits 9885 9993 +108
- Misses 3100 3126 +26
Partials 8 8 ☔ View full report in Codecov by Sentry. |
2038e4e
to
20f25df
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Core Booster support added https://github.com/GravityPDF/gravity-pdf-core-booster/pull/95 |
PDF for GravityView is not affected by the change, but doesn't currently make use of the temporary cache. Have opened issue about adding support https://github.com/GravityPDF/pdf-for-gravityview/issues/50 |
Enhanced Download support added https://github.com/GravityPDF/gravity-pdf-enhanced-download/pull/11 |
Bulk Generator is not affected by the change, but doesn't currently make use of the temporary cache. Have opened issue about adding support https://github.com/GravityPDF/gravity-pdf-bulk-generator/issues/184 |
Previewer not affected by the change, but doesn't make use of temporary cache. Have opened issue about it https://github.com/GravityPDF/gravity-pdf-previewer/issues/357 |
04741f0
to
2ea9244
Compare
PDF to image compatibility added https://github.com/GravityPDF/gravity-pdf-to-image/pull/11 (still maintains independent image cache; a separate issue was created to combine the two). |
2ea9244
to
f31eca4
Compare
Description
Automatically save PDFs to disk for up to 1 hour, and return the cached copy on subsequent requests (if it exists). This is a smart cache that auto-detects if the form, entry, or PDF settings have been modified and will generate a new PDF if that's the case.
Manually flushing the cache will be handled in a separate PR, alongside #1527
This PR standardizes the PDF generation system so all PDF generation processes (view/download/notification/preview/bulk generate/API) flow through the same set of functions/methods to create the documents and save them to the temporary cache:
The calling function/method to
Model_PDF::generate_and_save_pdf()
will then determine what to do with the saved PDF. When viewing/downloading documents, the PDF will be read from disk and streamed to the browser with appropriate browser caching headers. When sending notifications, the absolute path to the PDF is passed to wp_mail() as an attachment, when using the API the absolute path is returned etc.The
View_PDF::generate_pdf()
workflow to view/download PDFs is deprecated and should no longer be used directly, but for backwards compatibility will still work correctly.Testing instructions
This is a critical application path and should be thoroughly tested under all conditions to verify everything works as expected:
gfpdf_post_save_pdf
hook works as expected on form submissiongfpdf_override_pdf_bypass
hook bypasses the cachesave
option works as expected on form submissionadvanced_template
option on): view/download + notifications (as above)View_PDF::generate_pdf()
will view/download PDF as expected (including all URL params)gfpdfe_pdf_output_type
filter worksChecklist:
Additional Comments