wpsharks / comet-cache

An advanced WordPress® caching plugin inspired by simplicity.
https://cometcache.com
GNU General Public License v3.0
77 stars 18 forks source link

Nginx Optimization #766

Open raamdev opened 8 years ago

raamdev commented 8 years ago

It would be nice to have a panel for Nginx Optimization that provides Apache-equivalents for the .htaccess tweaks provided in the upcoming Apache Optimization panel.

Since we can't auto-insert things into the Nginx configuration files, this should simply be a list of configuration samples organized by type of optimization (GZIP, Leverage Browser Caching, etc.).

This panel should always be visible, but the contents of it should grey out with a note at the top indicating that Nginx was not detected.

jaswrks commented 8 years ago

Suggested Nginx Configuration Snippets

# CORS headers.
# Add these to the `http{}` block, or a `server{}` block.

map $uri $_access_control_allow_origin {
  default '';
  ~*\.(?:otf|ttf|woff|woff2|eot)$ '*';
}
add_header access-control-allow-origin $_access_control_allow_origin always;
# Leverage browser cache.
# Add these to the `http{}` block, or a `server{}` block.

if_modified_since exact;
etag on; # See: <http://jas.xyz/1MzvnWz>

map $uri $_expires {
  default 5d;
  ~*[^/]\.php(?:/|$) off;
}
expires $_expires;
# GZIP compression for compressable MIME types.
# Add these to the `http{}` block, or a `server{}` block.

gzip on;
gzip_vary on;
gzip_comp_level 6;

gzip_types text/xml text/plain # text/html (already implied)
  image/svg+xml application/rss+xml application/atom+xml application/xhtml+xml
  text/css application/json application/javascript application/x-php-source
  application/font-otf application/font-ttf;