Friday, November 23, 2018

Run the Django Oscar Sandbox Locally

git clone https://github.com/django-oscar/django-oscar.git

cd django-oscar

mkvirtualenv oscar  # needs virtualenvwrapper

make sandbox

The sandbox site (initialized with a sample set of products) will be available at: http://localhost:8000  

A sample superuser is installed with credentials:
username : superuser
email        : superuser@example.com
password : testing

Monday, November 19, 2018

nginx - Enable Leverage Browser Caching

If you are trying to enable Leverage Browser Caching for your site in nginx and it still shows not enabled in Google PageSpeed Insights and GTmetrix.

Solution :
1) Edit file /etc/nginx/sites-enabled/default
2) Add line
expires 365d;
in your virtualhost under "server {" above "location / {"
3) Restart nginx


Example :
server {
    listen 80;
    server_name yourdomainname.com;
    expires 365d;
    client_max_body_size 128M;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8080;
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;
        send_timeout                600;
        add_header X-Frame-Options SAMEORIGIN; 
        add_header X-Content-Type-Options nosniff; 
        add_header X-XSS-Protection "1; mode=block"; 
        proxy_hide_header X-Powered-By;
        server_tokens off;
        autoindex off;
        etag off;
    }

}