本文介绍了Rails 3:caches_page在开发中起作用,而不在生产中起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

caches_page在开发中起作用,而不在生产中起作用.在生产环境中,它会创建缓存,但会在每次访问时进行重写

caches_page works in development and not in production. In production it creates the cache but rewrites at each access

AppRuby::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

end

推荐答案

我的Web服务器是nginx.

my web server is nginx.

我的nginx.conf

My nginx.conf

user www-data;
worker_processes 16;
pid /var/run/nginx.pid;

worker_rlimit_nofile 10000;

events {
        worker_connections 8000;
       # multi_accept on;
}

http {

    include /etc/nginx/mime.types;
        default_type application/octet-stream;

        charset utf-8;

    #log
    access_log off;
        error_log /var/log/nginx/error.log;


        sendfile on;

    #Queremos enviar todos os cabeçalhos de resposta em um pacote. Isso permite que um cliente para começar a renderização de conteúdo imediatamente após o primeiro pacote chega
    tcp_nopush on;

    #Enviar pequenos pedaços de dados imediatamente
    tcp_nodelay on;

    #Tempo antes de solicitar nova pagina
    keepalive_timeout 30;

    #tempo limite para esperar dados do cliente
    client_body_timeout 10;
    client_header_timeout 10;   

    #Diminuir os requisitos de memória para armazenamento de cabeçalhos de solicitação (o padrão é 1024 bytes):
    client_header_buffer_size 128;

    # tamanho maximo de upload de arquivo
    client_max_body_size 10m;

        types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
        #server_tokens off;

        ##
        # Gzip Settings
        ##

        gzip on;
    gzip_http_version 1.1;

    #permite ou n a compressao da resposta para solicitacao proxy
    gzip_proxied any;

    #comprimento minimo da resposta a ser compactada(em bytes)
    gzip_min_length  500;

    #Desabilita a compressao se bater com a expressao abaixo
    gzip_disable "MSIE [1-6]\.";

    #permite a compressao desses tipos MIME
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    #nivel de compressao de 1 a 9   
        gzip_comp_level 4;


        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

我的文件在可用站点中

upstream unicorn_app.com {
    #server unix:/home/ubuntu/www/ruby/app.com/current/tmp/.sock
    server unix:/home/ubuntu/www/ruby/app.com/current/tmp/sockets/unicorn.sock fail_timeout=0;
}


server {
    listen 80;
    server_name subdominio.mydominio.com;
    root /home/ubuntu/www/ruby/app.com/current/public;

    #error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        #root /usr/share/nginx/www;
        root /home/ubuntu/www/ruby/app.com/current/public;
    }

    location / {

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
        #proxy_pass http://unicorn_server_app;
            if (!-f $request_filename) {
                proxy_pass http://unicorn_app.com;
                break;
            }
    }
}

这篇关于Rails 3:caches_page在开发中起作用,而不在生产中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:37