Skip to content

Proper cache control#599

Open
artoonie wants to merge 4 commits intomainfrom
proper-cache-control
Open

Proper cache control#599
artoonie wants to merge 4 commits intomainfrom
proper-cache-control

Conversation

@artoonie
Copy link
Owner

@artoonie artoonie commented Mar 4, 2026

From @skaphan:
Add updated_at field to JsonConfig model to track modification times
Use ConditionalGetMixin for all visualization views
Short-circuit 304 responses in VisualizeEmbedded before expensive computation

Local PR created to enable Heroku CI to run

skaphan and others added 2 commits February 24, 2026 13:29
Add updated_at field to JsonConfig model, use ConditionalGetMixin for
all visualization views, and short-circuit 304 responses in
VisualizeEmbedded before expensive computation.
Add proper cache control for embedded visualizations
@artoonie
Copy link
Owner Author

artoonie commented Mar 4, 2026

It looks like this is failing several of the caching tests:

FAIL: test_movie_task_without_celery (movie.tests.MovieCreationTestsMocked.test_movie_task_without_celery)
Test that the movie gets created when calling create_movie_task() directly
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.13/site-packages/mock/mock.py", line 1468, in patched
    return func(*newargs, **newkeywargs)
  File "/app/movie/tests.py", line 95, in test_movie_task_without_celery
    self.assertEqual(TextToSpeechCachedFile.objects.count(), 4)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 1 != 4
======================================================================
FAIL: test_cache_speed (visualizer.tests.testLiveBrowserHeadless.LiveBrowserHeadlessTests.test_cache_speed)
Tests that caching works and that second loads are faster,
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/visualizer/tests/testLiveBrowserHeadless.py", line 261, in test_cache_speed
    is_cache_much_faster(baseUrl, True)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/app/visualizer/tests/testLiveBrowserHeadless.py", line 247, in is_cache_much_faster
    self.assertGreater(avgLoadTimeWithoutCache, avgLoadTimeWithCache * 2)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 60.666666666666664 not greater than 119.33333333333333
======================================================================
FAIL: test_cache_works (visualizer.tests.testLiveBrowserHeadless.LiveBrowserHeadlessTests.test_cache_works)
Tests that caching doesn't call the heavy graph-generation function more than once
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.13/site-packages/mock/mock.py", line 1468, in patched
    return func(*newargs, **newkeywargs)
  File "/app/visualizer/tests/testLiveBrowserHeadless.py", line 289, in test_cache_works
    self.assertEqual(count_cache_misses_mocked(url), 0)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 1 != 0
----------------------------------------------------------------------
Ran 52 tests in 287.892s
FAILED (failures=3)

As well as some linter issues:

-----> Running test command `./scripts/run-tests.sh`...
Compressing... done
Compressed 22 block(s) from 26 template(s) for 1 context(s).
Checking for pylint issues
************* Module visualizer.views
visualizer/views.py:174:4: C0116: Missing function or method docstring (missing-function-docstring)
visualizer/views.py:182:12: C0103: Variable name "last_modified" doesn't conform to camelCase naming style (invalid-name)
visualizer/views.py:183:12: C0103: Variable name "if_modified_since" doesn't conform to camelCase naming style (invalid-name)
visualizer/views.py:185:16: C0103: Variable name "if_modified_since" doesn't conform to camelCase naming style (invalid-name)
visualizer/views.py:165:0: R0903: Too few public methods (1/2) (too-few-public-methods)
-----------------------------------
Your code has been rated at 9.99/10
These files must be perfectly linted
Checking for autopep8 differences
-----> test command `./scripts/run-tests.sh` failed with exit status 1

skaphan added 2 commits March 4, 2026 21:31
- Add pylint disable for too-few-public-methods (it is a mixin)
- Add docstring to get() method
- Rename last_modified/if_modified_since to camelCase

Co-Authored-By: Claude Opus 4.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants