Jump to content
php.lv forumi

nginx cache control


Recommended Posts

Radusies problēma ar nginx un caching. Uz production servera stāv nginx 1.2.3 (zinu, damn old versija, atbildīgajam uztaisīju ticket, lai apdeito, sen tā kā būtu laiks).

Ir projekta root folderis /public/. Šajā folderī ir 3 subfolderi /css/, /js/ un /images/. Nginx configi šiem folderiem:

        location ~ /css/ {
                include enable-gzip.conf;
                expires 2w;
        }
        location ~ /js/ {
                include enable-gzip.conf;
                expires 1M;
        }
        location /images/products/ {
                include enable-gzip.conf;
                expires 2w;
                try_files $uri /images/products/index.php;
        }
        location /images/ {
                expires 2w;
                include enable-gzip.conf;
        } 

enable-gzip.conf saturs:

gzip                    on;
gzip_disable            "MSIE [1-6]\.";
gzip_http_version       1.1;
gzip_comp_level         6;
gzip_types              text/plain text/css text/javascript application/x-javascript image/jpeg image/png;
gzip_buffers            16 8k;

Gan CSS, gan JS failiem ir GET parametrs "?mod=unixtime",  /js/jquery... failiem "?mod=static", savukārt attēliem tāda vispār nav.

Diemžēl atverot jebkuru lapu, šie faili netiek kešoti, līdz ar to lapa reāli ielādējas 2 sekundes katru reizi, kad tiek pārlādēta, kaut gan saturs tiek kešots un refreshojās tikai min. 1x stundā.

Visiem failiem HTTP response code ir 200 un Request headeri satur šādas līnijas: "Cache-Control:no-cache", "Pragma:no-cache".

 

 

Ir aizdomas, ka /images/ rūlis neuzliekās dziļākiem subfolderiem tajā mapē, tur ir vēl pa kategorijām un preču ID subfolderi, bet tas neattiecas uz css/js, kuros iekšā nav neviena subfoldera.

WTF is this and how do I fix it?

Edited by jurchiks
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...