We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Nginx Very Very Slow Load Images
-
- Posts: 19
- Joined: Sat Sep 28, 2013 9:41 pm
Nginx Very Very Slow Load Images
My friends, I recently installed vesta on a centos server and am running magento, made some minor changes and to my delight the pages open almost instant, but when the page contains many images, the problem happens. The strange thing is this test done in WebPagetest, with just a picture of 250k carries the load time to almost 11 seconds. Could anyone help me? because nginx is slow to serve as a simple image?
![Image](http://i44.tinypic.com/dcgcwy.png)
# Server globals
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Worker config
events {
worker_connections 19000;
use epoll;
}
http {
# Main settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_header_timeout 1m;
client_body_timeout 1m;
client_header_buffer_size 2k;
client_body_buffer_size 256k;
client_max_body_size 100m;
large_client_header_buffers 4 8k;
keepalive_timeout 1;
keepalive_requests 100000;
reset_timedout_connection on;
server_tokens off;
server_name_in_redirect off;
server_names_hash_max_size 1024;
server_names_hash_bucket_size 1024;
# Log format
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format bytes '$body_bytes_sent';
#access_log /var/log/nginx/access.log main;
access_log off;
# Mime settings
include /etc/nginx/mime.types;
default_type application/octet-stream;
expires 1y;
# Compression
gzip on;
gzip_vary on;
gzip_static on;
gzip_comp_level 9;
gzip_min_length 512;
gzip_buffers 8 64k;
gzip_http_version 1.1;
gzip_types text/plain text/js image/jpeg image/gif image/png image/x-icon f$
gzip_proxied any;
# Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
# SSL PCI Compliance
ssl_ciphers RC4:HIGH:!aNULL:!MD5:!kEDH;
ssl_session_cache shared:SSL:10m;
ssl_prefer_server_ciphers on;
# Error pages
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 502 503 504 /error/50x.html;
# Cache
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m$
proxy_temp_path /var/cache/nginx/temp;
proxy_cache_key "$host$request_uri $cookie_user";
proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header http_502;
proxy_cache_valid any 3d;
map $http_cookie $no_cache {
default 0;
~SESS 1;
~wordpress_logged_in 1;
}
# Wildcard include
include /etc/nginx/conf.d/*.conf;
}
![Image](http://i44.tinypic.com/dcgcwy.png)
# Server globals
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Worker config
events {
worker_connections 19000;
use epoll;
}
http {
# Main settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_header_timeout 1m;
client_body_timeout 1m;
client_header_buffer_size 2k;
client_body_buffer_size 256k;
client_max_body_size 100m;
large_client_header_buffers 4 8k;
keepalive_timeout 1;
keepalive_requests 100000;
reset_timedout_connection on;
server_tokens off;
server_name_in_redirect off;
server_names_hash_max_size 1024;
server_names_hash_bucket_size 1024;
# Log format
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format bytes '$body_bytes_sent';
#access_log /var/log/nginx/access.log main;
access_log off;
# Mime settings
include /etc/nginx/mime.types;
default_type application/octet-stream;
expires 1y;
# Compression
gzip on;
gzip_vary on;
gzip_static on;
gzip_comp_level 9;
gzip_min_length 512;
gzip_buffers 8 64k;
gzip_http_version 1.1;
gzip_types text/plain text/js image/jpeg image/gif image/png image/x-icon f$
gzip_proxied any;
# Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
# SSL PCI Compliance
ssl_ciphers RC4:HIGH:!aNULL:!MD5:!kEDH;
ssl_session_cache shared:SSL:10m;
ssl_prefer_server_ciphers on;
# Error pages
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 502 503 504 /error/50x.html;
# Cache
proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m$
proxy_temp_path /var/cache/nginx/temp;
proxy_cache_key "$host$request_uri $cookie_user";
proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header http_502;
proxy_cache_valid any 3d;
map $http_cookie $no_cache {
default 0;
~SESS 1;
~wordpress_logged_in 1;
}
# Wildcard include
include /etc/nginx/conf.d/*.conf;
}
Re: Nginx Very Very Slow Load Images
Configuration looks fine. Do you get same results with Firebug/Net module?
-
- Posts: 12
- Joined: Sat Jul 15, 2023 9:33 am
- Contact:
- Os: CentOS 7x
- Web: apache + nginx
Re: Nginx Very Very Slow Load Images
Here are few point you might consider to get this much of speed by ursing vestacp as I got my site google page speed is this.
![Image](https://snipboard.io/VguKdA.jpg)
On your Nginx Configuration update gzip types includes MIME types for images and adjust the expires directive for caching. The worker connections directive is set to 19000, which should be more than sufficient for most use cases, but ensure that your server file descriptor limit is not being reached. Implementing caching for static assets can greatly reduce load times for returning visitors. You might want to adjust the expires directive to ensure that browsers cache the images.
Make sure your images are optimized for the website. You can use any online compressor Tools like Jpeg Compressor, This can significantly reduce image file sizes without losing quality. Slow image loading might also be due to insufficient server resources. Check CPU, RAM, and especially disk I/O usage when images are being loaded. Using a CDN can significantly reduce image load times by serving your images from a location closer to the user and also offloading the traffic from your server.
If not already enabled, consider using HTTP/2 as it supports multiplexing, allowing multiple requests to be sent over a single TCP connection, which can improve the loading times for pages with many assets.
Also check for any network issues between your server and the clients, including latency and packet loss, which can impact load times. Since you're using Magento, consider using its built-in caching features and review any third-party extensions that might impact performance.
![Image](https://snipboard.io/VguKdA.jpg)
On your Nginx Configuration update gzip types includes MIME types for images and adjust the expires directive for caching. The worker connections directive is set to 19000, which should be more than sufficient for most use cases, but ensure that your server file descriptor limit is not being reached. Implementing caching for static assets can greatly reduce load times for returning visitors. You might want to adjust the expires directive to ensure that browsers cache the images.
Make sure your images are optimized for the website. You can use any online compressor Tools like Jpeg Compressor, This can significantly reduce image file sizes without losing quality. Slow image loading might also be due to insufficient server resources. Check CPU, RAM, and especially disk I/O usage when images are being loaded. Using a CDN can significantly reduce image load times by serving your images from a location closer to the user and also offloading the traffic from your server.
If not already enabled, consider using HTTP/2 as it supports multiplexing, allowing multiple requests to be sent over a single TCP connection, which can improve the loading times for pages with many assets.
Also check for any network issues between your server and the clients, including latency and packet loss, which can impact load times. Since you're using Magento, consider using its built-in caching features and review any third-party extensions that might impact performance.