[ASK] Cara Cache Static Content Di Nginxcp

Discussion in 'Software Hosting dan Control Panel' started by prandah, 26 Aug 2011.

Thread Status:
Not open for further replies.
  1. prandah

    prandah Poster 2.0

    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    Halo semuanya ,
    saya mau nanyak nih cara cache static content gimana yah ?
    yang mau di cache seprti jpg | gif | png | css | js + dll

    saya sudah menggunakan tambahan mod untuk cache di .htaccess tapi hasilnya sama saja gak berguna

    HTML:
    <ifModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 seconds"
    ExpiresByType text/html "access plus 1 seconds"
    ExpiresByType image/gif "access plus 259200000 seconds"
    ExpiresByType image/jpeg "access plus 259200000 seconds"
    ExpiresByType image/png "access plus 259200000 seconds"
    ExpiresByType text/css "access plus 60480000 seconds"
    ExpiresByType text/javascript "access plus 21600000 seconds"
    ExpiresByType application/x-javascript "access plus 21600000 seconds"
    </ifModule>
    
    
    <ifModule mod_headers.c>
    <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=25920000, public"
    </filesMatch>
    <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=6048000, public"
    </filesMatch>
    <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=2160000, private"
    </filesMatch>
    <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=2160000, public, must-revalidate"
    </filesMatch>
    <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"
    </filesMatch>
    </ifModule>
    
    
    <ifModule mod_headers.c>
    Header unset ETag
    </ifModule>
    
    FileETag None
    <ifModule mod_headers.c>
    Header unset Last-Modified
    </ifModule> 
    

    nuhun pencerahan :D
     
  2. cpserv

    cpserv Expert 1.0

    Messages:
    866
    Likes Received:
    123
    Trophy Points:
    43
    cache static pake nginx? di virtualhostnya nginx bos. nginx ga kenal .htaccess. nginxcp tu yg bayar ya? saya pake nginxadmin. jd kurang tau letak vhostnya ada dimana. coba aja dicari dulu.

    edit atau tambahin klo blom ada:

    Code:
        location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
            access_log off;
            expires max;
        }
    
        location ~* ^.+\.(css|js)$ {
            access_log off;
            expires max;
        }
     
  3. prandah

    prandah Poster 2.0

    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    halo ,
    setelah saya edit
    saya update jadi gini

    HTML:
    user  nobody;
    # no need for more workers in the proxy mode
    worker_processes  2;
    error_log  /var/log/nginx/error.log info;
    worker_rlimit_nofile 20480;
    events {
     worker_connections 5120; # increase for busier servers
     use epoll; # you should use epoll here for Linux kernels 2.6.x
    }
    http {
     server_name_in_redirect off;
     server_names_hash_max_size 10240;
     server_names_hash_bucket_size 1024;
     include    mime.types;
     default_type  application/octet-stream;
     server_tokens off;
     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;
     keepalive_timeout  5;
     gzip on;
     gzip_vary on;
     gzip_disable "MSIE [1-6]\.";
     gzip_proxied any;
     gzip_http_version 1.1;
     gzip_min_length  1000;
     gzip_comp_level  6;
     gzip_buffers  16 8k;
    # You can remove image/png image/x-icon image/gif image/jpeg if you have slow CPU
     gzip_types    text/plain text/xml text/css application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg application/xml+rss text/javascript application/atom+xml;
     ignore_invalid_headers on;
     client_header_timeout  3m;
     client_body_timeout 3m;
     send_timeout     3m;
     reset_timedout_connection on;
     connection_pool_size  256;
     client_header_buffer_size 256k;
     large_client_header_buffers 4 256k;
     client_max_body_size 200M; 
     client_body_buffer_size 128k;
     request_pool_size  32k;
     output_buffers   4 32k;
     postpone_output  1460;
     proxy_temp_path  /tmp/nginx_proxy/;
     client_body_in_file_only on;
     log_format bytes_log "$msec $bytes_sent .";
     include "/etc/nginx/vhosts/*";
    }
    
        location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
            access_log off;
            expires max;
        }
    
        location ~* ^.+\.(css|js)$ {
            access_log off;
            expires max;
        }
    
    betul gak yah ??
    soalnya webnya jadi gak mau di akses :D
    saya pakek nginxcp.com aka nginxadmin yang versi free
     
  4. cpserv

    cpserv Expert 1.0

    Messages:
    866
    Likes Received:
    123
    Trophy Points:
    43
    ngga. :p

    itu kan di nginx.conf!? tuh keliatan dibilang `include "/etc/nginx/vhosts/" `

    Code:
    cat /etc/nginx/vhosts/namadoma.in
    harusnya ada line :

    Code:
    location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
    yg isinya

    Code:
    expires 7d;
    try_files $uri @backend;
    harusnya sih udah otomatis disitu dia ngecache. ga pengaruhnya gimana ya?
     
  5. prandah

    prandah Poster 2.0

    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
  6. cpserv

    cpserv Expert 1.0

    Messages:
    866
    Likes Received:
    123
    Trophy Points:
    43
    mmm,, yg disini udah solved blom?


    btw, ini lagi nyoba webpagetest. koq ga muncul2 ya hurup2nya? lama bener nungguinnya inih.. hahaha
     
  7. prandah

    prandah Poster 2.0

    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    udah tapi pakek filecache
    gak jadi pakek xCache :D
     
  8. cpserv

    cpserv Expert 1.0

    Messages:
    866
    Likes Received:
    123
    Trophy Points:
    43
    mmm,, setelah diperhatiin kayaqnya cuma salah baca aja dia.

    berhubung nginx admin cm reverse proxy, semua dijalanin di belakang. sedangkan yg dibaca sama webpagetest itu cm http headernya aja.

    kayaqnya lho.. :p

    yg jelas dia ngecache klo diliat dari loadnya..

    Code:
    First View	4.634s	0.440s	1.310s	4.634s	50	538 KB	4.844s	51	540 KB
    Repeat View	1.908s	0.373s	0.624s	1.908s	13	63 KB	1.948s	13	63 KB
     
  9. prandah

    prandah Poster 2.0

    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    owh berarti secara backend server udah nge cache yak :D
    y udah case closed berarti :D
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...