Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having a dynamic website,which is running on nginx and php-fpm.

Can there be any performance improvement if images,Audio Files,css,js files are put into a seperate directory. here is my current setup:

location /var/www/kk/images {
            root   /var/www/kk/images;
            autoindex on;
                   }

location /var/www/kk/js {
            root   /var/www/kk/js;
            autoindex off;

    }

location /var/www/kk/css {
            root   /var/www/kk/css;
            autoindex off;

    }

location /var/www/kk/audio {
            root   /var/www/kk/audio;
            autoindex off;

    }

If this is not the best way.Can u tell me why and also Is there a better way to do this?

share|improve this question
1  
Hm... do your actually URLs looks like http://example.com/var/www/kk/audio/file.mp3 and files is located in the /var/www/kk/audio/var/www/kk/audio directory? –  VBart Nov 21 '12 at 10:19
    
location is correct but url is not like that,it is encoded. –  Kevin Parker Nov 23 '12 at 16:05
    
Are you sure? /var/www/kk/audio/var/www/kk/audio doesn't look like correct one. –  VBart Nov 23 '12 at 16:34
    
yes yes you are right..calls are made like file1.mp3 file2.mp3 from /var/www/kk/audio/ –  Kevin Parker Nov 24 '12 at 6:36

1 Answer 1

there's advantage of keeping static content in separate folder than php scripts. for instance you can set expires header for css/js/images etc by using the expires directive:

location /var/www/kk/audio {
            root   /var/www/kk/audio;
            autoindex off;
            expires 30d;
    }

to speed up page loading time you might consider hosting those assets from another domain... and some day use the cdn in the origin pull mode to give you even better performance.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.