You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BACK STORY
For GTM, I needed to add a couple entries to our CSP (so the debugger could load).
The current approach is in middleware.py and we’re creating a dictionary of lists, then appending strings to those lists based on environment. (e.g. style-src is set to ['self', 'unsafe-inline', data:] and we append https://fonts.googleapis.com https://tagmanager.google.com/ https://www.googletagmanager.com/debug/ for not-prod)
Laura had commented that we could use extend when we’re adding more than one, rather than adding a single string of multiple items to the end of a list. Out of curiosity, I looked into the performance differences between append and extend.
FINDINGS extend takes an average of .3 seconds longer than the same append.
Worse: the timeit function fires every time any asset is requested*—for every page, every image…
*Am I reading it incorrectly? Is it happening only for localhost?
QUESTION
What d’you think about setting the various CSP string values somewhere like settings/production.py, dev.py, etc? These values are set at deploy and never change*—seems wasteful to re-calculate them every time any asset is requested
*apart from additions for when a user is logged in to the CMS
BACK STORY
For GTM, I needed to add a couple entries to our CSP (so the debugger could load).
The current approach is in middleware.py and we’re creating a dictionary of lists, then appending strings to those lists based on environment. (e.g.
style-src
is set to['self', 'unsafe-inline', data:]
and we appendhttps://fonts.googleapis.com https://tagmanager.google.com/ https://www.googletagmanager.com/debug/
for not-prod)Laura had commented that we could use
extend
when we’re adding more than one, rather than adding a single string of multiple items to the end of a list. Out of curiosity, I looked into the performance differences betweenappend
andextend
.FINDINGS
extend
takes an average of .3 seconds longer than the same append.Worse: the timeit function fires every time any asset is requested*—for every page, every image…
*Am I reading it incorrectly? Is it happening only for localhost?
QUESTION
What d’you think about setting the various CSP string values somewhere like settings/production.py, dev.py, etc? These values are set at deploy and never change*—seems wasteful to re-calculate them every time any asset is requested
*apart from additions for when a user is logged in to the CMS
Logs
these are the logs for the homepage:
The text was updated successfully, but these errors were encountered: