您页面上的任何静态文件都应该由您的Web服务器提供服务,例如Apache。除非您必须阻止某些人访问某些文件,否则django不应参与其中。
在这里,
I found an example of how to do it
:
# our production setup includes a caching load balancer in front.
# we tell the load balancer to cache for 5 minutes.
# we can use the commented out lines to tell it to not cache,
# which is useful if we're updating.
<FilesMatch "\.(html|js|png|jpg|css)$">
ExpiresDefault "access plus 5 minutes"
ExpiresActive On
#Header unset cache-control:
#Header append cache-control: "no-cache, must-revalidate"
</FilesMatch>