[英]changing 'DEFAULT_FILE_STORAGE' causing high TTFB ( waiting time ) with boto3
...
AWS_ACCESS_KEY_ID = 'MY_KEY'
AWS_SECRET_ACCESS_KEY = 'MY_SECRET_KEY'
AWS_STORAGE_BUCKET_NAME = 'wallpapers'
AWS_S3_ENDPOINT_URL = 'https://sgp1.digitaloceanspaces.com'
AWS_S3_CUSTOM_DOMAIN = 'wallpapers.sgp1.cdn.digitaloceanspaces.com'
AWS_QUERYSTRING_AUTH = False
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
AWS_DEFAULT_ACL = 'public-read'
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, 'media')
MEDIA_ROOT = 'media/'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
...
when I open 'http://127.0.0.1:8000/'当我打开'http://127.0.0.1:8000/'
but when I comment out/ remove this in settings.py... #DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
但是当我在 settings.py 中注释掉/删除它时...
#DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
then everything works fine然后一切正常
I realized the real problem was caused by a template tag.我意识到真正的问题是由模板标签引起的。
<p>{{ my_img.width }}</p>
so in order to get the width of the image stored in MySQL, it was downloading the chunks of the image and then calculating the dimensions.因此,为了获得存储在 MySQL 中的图像的宽度,它正在下载图像的块,然后计算尺寸。 to overcome this I added separate fields in my model.py for image height and width.
为了克服这个问题,我在 model.py 中为图像高度和宽度添加了单独的字段。 it worked... I m new to Django.
它起作用了......我是 Django 的新手。 it might not be the best approach.
这可能不是最好的方法。 please let me know for a better solution.
请让我知道以获得更好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.