PDF for GravityView Hooks – gfpdf_gv_render_budget_window
Description
Change the length of the window the render budget is measured over. The default is five minutes. When a window ends, the visitor's full budget is restored, and unused budget doesn't carry over. Each visitor's window is offset slightly, so budgets don't all reset at the same moment.
A longer window with the same budget lowers the rate a visitor can sustain, and a refused visitor waits longer before trying again. A shorter window does the opposite. When you change the window, scale the budget to match with gfpdf_gv_render_budget.
See Caching and Rate Limiting. Related hooks: gfpdf_gv_render_budget_exempt_caps and gfpdf_gv_render_budget_logged_in_multiplier.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$window | int
- The length of the window, in seconds.
- Values below
1are treated as1. - The default value is
300(five minutes).
$context | string
- Which PDF type the window is for.
- Valid values include:
singledirectory(Multiple Entries PDF)
$logged_in | bool
- Whether the visitor is logged in.
Usage
Use a one-minute window, and cut the budget to a fifth to keep the same rate:
add_filter( 'gfpdf_gv_render_budget_window', function( $window, $context, $logged_in ) {
return MINUTE_IN_SECONDS;
}, 10, 3 );
add_filter( 'gfpdf_gv_render_budget', function( $max, $context, $logged_in ) {
return (int) ceil( $max / 5 );
}, 10, 3 );
Source Code
This filter is located in src/Pdf/Access/RenderBudget.php of the PDF for GravityView extension.