Skip to content

Commit 526bc8f

Browse files
committed
simplify _cached_static_contents
1 parent 4cc86aa commit 526bc8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/django_idom/components.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
@component
1010
def static_css(static_path: str):
1111
"""Fetches a CSS static file for use within IDOM. This allows for deferred CSS loading."""
12-
return html.style(_cached_static_contents(static_path, "css_contents"))
12+
return html.style(_cached_static_contents(static_path))
1313

1414

1515
@component
1616
def static_js(static_path: str):
1717
"""Fetches a JS static file for use within IDOM. This allows for deferred JS loading."""
18-
return html.script(_cached_static_contents(static_path, "js_contents"))
18+
return html.script(_cached_static_contents(static_path))
1919

2020

21-
def _cached_static_contents(static_path: str, cache_name: str):
21+
def _cached_static_contents(static_path: str):
2222
# Try to find the file within Django's static files
2323
abs_path = find(static_path)
2424
if not abs_path:
@@ -28,7 +28,7 @@ def _cached_static_contents(static_path: str, cache_name: str):
2828

2929
# Fetch the file from cache, if available
3030
last_modified_time = os.stat(abs_path).st_mtime
31-
cache_key = f"django_idom:{cache_name}:{static_path}"
31+
cache_key = f"django_idom:static_contents:{static_path}"
3232
file_contents = IDOM_CACHE.get(cache_key, version=last_modified_time)
3333
if file_contents is None:
3434
with open(abs_path, encoding="utf-8") as static_file:

0 commit comments

Comments
 (0)