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
{{ message }}
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
I save uploaded image by users into Storage folder with customized path. The image's name will be parsed to know where image will be save in my Storage. Therefore, I write function to return image data when user request image by GET method. It means that image is not get directly. For example, user requests:
I get image name (in this case, d3fe6896b9dcbc02031eaf36761009c6.jpg) and parse it to know where I save the image in Storage folder. Before applying PageSpeed, image is loaded normally. However, image is not found (404 error) after I use PageSpeed for optimizing. I don't modify any PageSpeed Filters (use CoreFilters). My ssl.conf in nginx as following:
pagespeed on;
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location ~* .(woff|eot|ttf|svg|mp4|webm|jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
When debugging, I see that my code for response image can not reach.
//PHP code
//Parse image name and generate full path
//After that, get image data and response to client
$imageFile = File::get($fullPath);
return response($imageFile, 200)->header('Content-type', 'image/jpeg');
Therefore, I think that PageSpeed fetched image link before my code. As a result, image is not found.
How to solve the problem?
The text was updated successfully, but these errors were encountered:
Hi -- I am not sure I fully understand the problem. If you have PHP code manipulating your image links, that should not be affected by PageSpeed because PageSpeed runs after PHP (or at least it should>
However, if you have javascript code that is sensitive to URL syntax, that can indeed be disturbed by PageSpeed's URL manipulations. In that case, one solution is to use "pagespeed ImagePreserveUrls on" or "OptimizeForBandwidth", so that you get the benefits of image file reduction, without the risk of URL modification.
Note that in that case you will not get the benefit of image inlining or cache extension (though given your PHP you probably don't need cache extension).
I save uploaded image by users into Storage folder with customized path. The image's name will be parsed to know where image will be save in my Storage. Therefore, I write function to return image data when user request image by GET method. It means that image is not get directly. For example, user requests:
https://example.com/image/d3fe6896b9dcbc02031eaf36761009c6.jpg
I get image name (in this case, d3fe6896b9dcbc02031eaf36761009c6.jpg) and parse it to know where I save the image in Storage folder. Before applying PageSpeed, image is loaded normally. However, image is not found (404 error) after I use PageSpeed for optimizing. I don't modify any PageSpeed Filters (use CoreFilters). My ssl.conf in nginx as following:
When debugging, I see that my code for response image can not reach.
//PHP code
//Parse image name and generate full path
//After that, get image data and response to client
$imageFile = File::get($fullPath);
return response($imageFile, 200)->header('Content-type', 'image/jpeg');
Therefore, I think that PageSpeed fetched image link before my code. As a result, image is not found.
How to solve the problem?
The text was updated successfully, but these errors were encountered: