Add support for proxy_cache_background_update - #195
Open
florentianayuwono with Copilot wants to merge 2 commits into
Open
Add support for proxy_cache_background_update#195florentianayuwono with Copilot wants to merge 2 commits into
florentianayuwono with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for proxy_cache_background_update
Add support for proxy_cache_background_update
Jul 7, 2026
florentianayuwono
marked this pull request as ready for review
July 7, 2026 16:12
florentianayuwono
requested review from
alithethird and
Copilot
and removed request for
a team
July 7, 2026 16:12
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds support for nginx proxy_cache_background_update via a new charm config option, enabling stale responses to be served while expired cache entries refresh in the background.
Changes:
- Added
proxy_cache_background_updateboolean option to charm config and mapped it to an Nginx directive. - Extended env-config generation with
NGINX_CACHE_BACKGROUND_UPDATE(on/off) and rendered it in the nginx template. - Updated/added unit tests and nginx config fixtures to cover enabled/disabled rendering.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
config.yaml |
Adds operator-facing config option with docs about cache_use_stale interaction. |
src/charm.py |
Converts new config option into an env var consumed by nginx template rendering. |
content-cache_rock/nginx_cfg.tmpl |
Emits proxy_cache_background_update directive in generated nginx config. |
tests/unit/test_charm.py |
Adds unit tests validating env var generation and template output. |
tests/files/nginx_config*.txt |
Updates and adds fixtures to include the new directive. |
Comments suppressed due to low confidence (1)
src/charm.py:1
- When
proxy_cache_background_updateis enabled butcache_use_staledoes not includeupdating, nginx won’t serve stale content during background refresh (the primary value of enabling this feature). Consider adding a runtime validation: if background update isonandupdatingis missing fromcache_use_stale, either (a) log a clear warning and proceed, or (b) automatically appendupdating(and document that behavior). This helps operators avoid a silent misconfiguration.
#!/usr/bin/env python3
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+659
to
+663
| config = self.config | ||
| harness = self.harness | ||
| harness.disable_hooks() | ||
| config["proxy_cache_background_update"] = True | ||
| harness.update_config(config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds nginx
proxy_cache_background_updatesupport, allowing stale cached responses to be served while an expired item is refreshed in the background.Changes
config.yaml: Newproxy_cache_background_updateboolean option (default:false). Documents thatupdatingmust be present incache_use_stale(already in the default value — backward compatible).src/charm.py: Converts config toNGINX_CACHE_BACKGROUND_UPDATEenv var ("on"/"off").content-cache_rock/nginx_cfg.tmpl: Addsproxy_cache_background_updatedirective afterproxy_cache_revalidate.JUJU_ENV_CONFIGand all nginx config fixture files.Test plan
Unit tests cover env config generation and nginx config rendering for both enabled/disabled states. All 39 tests pass.
Review focus
Per nginx docs,
proxy_cache_background_update onrequiresupdatinginproxy_cache_use_stale. The defaultcache_use_stalealready includesupdating, so no forced coupling was added — users who customisecache_use_staleto omitupdatingare responsible for the interaction.What this PR does
Adds a new
proxy_cache_background_updatecharm config option that maps to the nginx directive of the same name, enabling background cache refresh while serving stale content.Why we need it
Allows operators to enable nginx's background update behaviour for expired cache entries, improving perceived latency by returning stale content immediately while revalidating in the background.
Checklist
docs/changelog.mdwith user-relevant changesdocs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the labelno-release-note.(e.g., in
.github/workflows/integration_tests.yaml, ensure themoduleslist is correct)