Skip to content

Improve PDF performance - #4425

Open
svenseeberg wants to merge 1 commit into
developfrom
fix/pdf-cache
Open

Improve PDF performance#4425
svenseeberg wants to merge 1 commit into
developfrom
fix/pdf-cache

Conversation

@svenseeberg

@svenseeberg svenseeberg commented Jul 10, 2026

Copy link
Copy Markdown
Member
  • Make check for existing cached PDF faster.
  • Execute compute heavy queries only when no cached PDF exists.
  • Generate PDF file in temp dir and move to download dir when done to mitigate race condition between 2 processes.

@timobrembeck timobrembeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks a lot! 🚀

A minor suggestion: the existing tests guard correctness but not the performance goal. A small test using pytest-django's django_assert_num_queries (or asserting the hash-path SQL does not select content) would protect it. Optional, but cheap insurance.

Comment thread integreat_cms/cms/utils/pdf_utils.py Outdated
Comment thread integreat_cms/cms/utils/pdf_utils.py Outdated

@jonbulz jonbulz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, thanks! I think once @timobrembeck's comments are addressed this is ready to go. 👍

Comment thread integreat_cms/cms/models/abstract_content_model.py Outdated
@jonbulz jonbulz added this to the Backlog milestone Jul 22, 2026
@connium connium added the prio: low Not urgent, can be resolved in the distant future. label Aug 26, 2026
@svenseeberg
svenseeberg force-pushed the fix/pdf-cache branch 2 times, most recently from dd88471 to 6e54b41 Compare August 27, 2026 10:38
@svenseeberg

Copy link
Copy Markdown
Member Author

Actually, the approach does not really work. Just deferring the content field does not really yield that much of an improvement. I'll try to improve the hash loop.

@svenseeberg
svenseeberg marked this pull request as draft August 27, 2026 10:58
@svenseeberg

Copy link
Copy Markdown
Member Author
image

@svenseeberg
svenseeberg force-pushed the fix/pdf-cache branch 2 times, most recently from d70275b to f07de47 Compare August 27, 2026 13:19
@svenseeberg
svenseeberg marked this pull request as ready for review August 27, 2026 13:20
@svenseeberg
svenseeberg force-pushed the fix/pdf-cache branch 2 times, most recently from 503626c to b99d866 Compare August 31, 2026 07:46
* Execute compute heavy page fetches only if no PDF exists
* Add test to limit number of SQL queries on cache hit
* Generate PDF file in temp dir and move to download dir
  when done to mitigate race condition between 2 processes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio: low Not urgent, can be resolved in the distant future.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants