@@ -151,7 +151,7 @@ class ReactPyApp:
151151 to a user provided ASGI app."""
152152
153153 parent : ReactPy
154- _cached_index_html = ""
154+ _index_html = ""
155155 _etag = ""
156156 _last_modified = ""
157157
@@ -173,8 +173,8 @@ async def __call__(
173173 return
174174
175175 # Store the HTTP response in memory for performance
176- if not self ._cached_index_html :
177- self .process_index_html ()
176+ if not self ._index_html :
177+ self .render_index_template ()
178178
179179 # Response headers for `index.html` responses
180180 request_headers = dict (scope ["headers" ])
@@ -183,7 +183,7 @@ async def __call__(
183183 "last-modified" : self ._last_modified ,
184184 "access-control-allow-origin" : "*" ,
185185 "cache-control" : "max-age=60, public" ,
186- "content-length" : str (len (self ._cached_index_html )),
186+ "content-length" : str (len (self ._index_html )),
187187 "content-type" : "text/html; charset=utf-8" ,
188188 ** self .parent .extra_headers ,
189189 }
@@ -203,12 +203,12 @@ async def __call__(
203203 return await response (scope , receive , send ) # type: ignore
204204
205205 # Send the index.html
206- response = ResponseHTML (self ._cached_index_html , headers = response_headers )
206+ response = ResponseHTML (self ._index_html , headers = response_headers )
207207 await response (scope , receive , send ) # type: ignore
208208
209- def process_index_html (self ) -> None :
210- """Process the index.html and store the results in memory ."""
211- self ._cached_index_html = (
209+ def render_index_template (self ) -> None :
210+ """Process the index.html and store the results in this class ."""
211+ self ._index_html = (
212212 "<!doctype html>"
213213 f'<html lang="{ self .parent .html_lang } ">'
214214 f"{ vdom_head_to_html (self .parent .html_head )} "
@@ -217,8 +217,7 @@ def process_index_html(self) -> None:
217217 "</body>"
218218 "</html>"
219219 )
220-
221- self ._etag = f'"{ hashlib .md5 (self ._cached_index_html .encode (), usedforsecurity = False ).hexdigest ()} "'
220+ self ._etag = f'"{ hashlib .md5 (self ._index_html .encode (), usedforsecurity = False ).hexdigest ()} "'
222221 self ._last_modified = formatdate (
223222 datetime .now (tz = timezone .utc ).timestamp (), usegmt = True
224223 )
0 commit comments