Disable cache for "site create -wp"


#1

I installed a simple WP website using ee site create --wp and it seems that my static assets files are cached anyway:

$ curl -X GET -I http://www.mysite.com/style.css

HTTP/1.1 200 OK
Server: nginx
Content-Type: text/css
Content-Length: 914
Connection: keep-alive
Vary: Accept-Encoding
ETag: "55b02769-392"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Access-Control-Allow-Origin: *
Accept-Ranges: bytes
Date: Thu, 23 Jul 2015 16:38:54 GMT

The caching seems to be due to the following lines in /etc/nginx/common/locations.conf:

# Cache static files
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|.......|rtf|swf)$ {
    add_header "Access-Control-Allow-Origin" "*";
    access_log off;
    log_not_found off;
    expires max;
}

so I commented out the include common/locations.conf; line using ee site edit which reloaded the server config. But still the files are being cached.

So I tried to do some cache busting with WP and added the following lines in the functions.php

function enqueue_parent_theme_style() {
    ...
    wp_enqueue_style( 'mfn-child-style', get_stylesheet_directory_uri() .'/style.css', false, 'filemtime(get_stylesheet_directory() . 'style.css')' );    
    ...
} 

With no success.

This caching issue is quite annoying for development. Does anyone can help?


#2

If you are developing a theme use in wp-config.php

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files) define(‘SCRIPT_DEBUG’, true);


#3

It works perfectly for development. Thanks!


#4

Acutally it works for a little while. And then the issue is back after a few hours. Really weird!


#5