@rhand GZIP compression is usually configured at the server level, i.e. you would configure Apache or nginx to apply the correct headers and compress files before sending them to the end user.
Store Images Gzipped on Digital Ocean Bucket
We need to adjust our image storage at Digital Ocean Spaces to the images are served gzipped compressed. This will allow better loading of the images by all browsers. So was thinking about using PHP gzencode. And so far I have come up with this code"
$gzippedImage = gzencode(file_get_contents($request->file->getRealPath()));
\Storage::disk('do')->put("uploads/{$this->currentProject->id}/" . $request->size . '_' . $request->name, $gzippedImage,
[
'visibility' => 'public',
// 'ContentType' => 'image/subtype',
'ContentEncoding'=> 'gzip',
]);
The main thing I wonder about is the Content Type for each image type. Will a content type like image/png be sent along via the storage class as default meta data? Or do I need to send the ContentType along?
If not I guess I would have to check for mime type and then add a ContentType. If so how could I do that with the storage class?
@rhand But that’s exactly what a CDN is for. Services like CloudFront, will request your files from an origin (your website), do any compressing, and then save that cached version of the file and serve the cached version on subsequent requests. Queues have nothing to do with it.
Please or to participate in this conversation.