I'm hosting a static website on Amazon S3. It's basically a theme with all static files (HTML, CSS, JS & Image files)
Everything works fine. I've also activated Cloudfront. But the site is still sluggish and very slow while loading. So I wanted to gzip the content & started to follow this doc Serving Compressed Files from Amazon S3
But the part where I've to go to 2000+ files and update Metadata as "Content-Encoding" as "gzip" is too tedious and isn't practical for me.
Is there a way I can add this metadata while I compress the files using gzip.exe on my local system?
Or any other workaround?
Please guide me. I'm stuck. :(
Related
I am currently working on a small Django project that is deployed on Heroku. In order to optimize the website's performance, I decided to use the django-compressor package to merge and minify all the JavaScript and CSS files. I am using the offline compression option, as it is the only one that works on Heroku.
However, I have noticed that the compressed CSS and JS files are not being gzipped when delivered to the client. This is causing the benefits I gained from using the compressor to be lost. I have been trying to find a solution to this issue, but I have not been able to find an easy way to turn on gzip for the compressor when using offline compression.
I would like to avoid a complex setup with S3, as this is a small site and I am looking for a simple solution that can be easily implemented on Heroku.
My question is:
Is there an easy way to turn on gzip for compressor when using offline compression? And how can I implement it on Heroku?
I would greatly appreciate any help or suggestions on how to solve this problem. Thank you in advance.
I am trying to make a django application (with the Rest framework) and I was just researching and came across different ways to serve media files.
what is the recommended approach for a project/app that lets you upload pictures so that other users can download them?
I came across CDN such as uploadcare, cloudinary and then ofcourse amazon S3 as well. Is there a difference in using these services like uploadcare vs S3 in terms of speed or scaling?
thanks in advance,
I build a website with Django and now hosting it. I used Whitenoise to serve images but only static ones shows up when debug is False. How can I serve media files uploaded by users too? Since it is my first development with Django detailed help would be much appreciated kind folk of the Stack.
I reached my host provider's support and thanks to them I saw it was not that hard. Since I am using a shared host they was conigured serving files defult with CloudLinux. All I have to do is take static and media files on public_html folder. And change the media root for here because I want users uploaded images to get here too. To sum up solution is public_html folder.
I have a severless website that I am quite happy with. Unfortunately, there are files in my assets folder that I would rather not be served, and I am not sure how to achieve this.
As an example, S3 bucket mywebsite.com has several HTML files and an assets folder. If I go to mywebsite.com/assets/images/image.png CloudFront serves it up.
This isn't too concerning. But some of the JS stuff with API endpoints, etc should not exposed like this.
Any advice is much appreciated.
Sincerely,
ngp
I am looking into possibly setting up a CDN to use with my Wagtail sites. I am thinking that this will be a more efficient way to manage media uploads during stage/production pushes, since right now the media folder has to be manually copied from server to server on deploy. If all of the images were being accessed from a CDN then this wouldn't be an issue.
This would be my first time using a CDN so I'm looking for advice. There is lots of info on using a CDN with WordPress, but not a lot of documentation on setting one up with Wagtail/Django. I have the following questions about it:
Does anyone have any suggestions on the best way to implement the CDN with Wagtail?
How does it handle the uploads that the user submits through the CMS? Most of the images will be uploaded as part of the static files, but how does it work when the user uploads a photo as part of a post?
Which CDN companies have you had the best/worst experiences with? The sites I am planning to use this for are professional/business, but not e-commerce.
Also, if there is a more efficient way to handle the transfer of media uploads from one environment to another than using a CDN, I'd love to hear your suggestions for that too. As of right now I've had to copy the media folder over after doing the deploy, and I will have to do this every time I make a change to the site.
Thanks in advance for your assistance.
The following resources can be helpful for your required setup in Wagtail (later on today I can provide you some more details):
Frontend cache invalidator for pages (so not only for static and media files)
Link: http://docs.wagtail.io/en/latest/reference/contrib/frontendcache.html#frontendcache-aws-cloudfront
Storing media files in Amazon Web Services S3 buckets
This should be a better solution instead of copying media files from server to server. In this case Amazon Web Services CloudFront (CDN) would be a perfect choice.
Link: https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#amazon-s3
More info CloudFront: https://aws.amazon.com/cloudfront/
Static file cache invalidation with Django Whitenoise
Can be relevant to clear the cache for a new deployment (the static files will have a unique filename so CDN will have a new file cache from its origin after the deployment)
Link: http://whitenoise.evans.io/en/stable/django.html
CloudFront from AWS will have my personal choice for CDN. Besides the awesome resources/services AWS has to offer, CloudFront is simple to setup and has one of the best CDN's out there.
Finally a CDN for serving static- and media files has nothing to do with Wagtail specifically. There are some (see list above) nice apps available for Django itself, but you are free to choose another CDN solution (like Cloudflare).
So setting up a AWS S3 Bucket for each environment (tst/acc/stg/prd) and use it for uploading you media files (so the files aren't on the server anymore) and setup a CloudFront distribution for these buckets would be a proper solution for your problem.
Best regards,
Rob Moorman