A
A
av_tyschenko2018-12-30 14:00:10
Nginx
av_tyschenko, 2018-12-30 14:00:10

How to load html cache from external nginx server?

Friends, for some time now I have been trying to find a solution for loading the cache through the domain. I use the Super Cache plugin in WordPress.
Now the files are loaded by the line from the main domain example.tdl :

# Если кеша нет, тогда отправляемся к WordPress, чтобы он его нам создал
  location / {
        index index.php index.html;
        try_files /wp-content/cache/supercache/${http_host}${cache_uri}index.html /wp-content/cache/supercache/${http_host}${cache_uri}index-https.html $uri $uri/ /index.php?$args ;
  }

But here's the moment. I need it to load from the cdn.example.tdl domain and use the domain at the beginning of the "/wp-content/cache/supercache/" line. Is it possible to do this somehow. Perhaps this should not be done with the location function. I'm in nginx full 0.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2018-12-30
@grinat

server {
   server_name cdn.example.tdl;
   # тут проверяешь наличие кэша, если файла нет, то сработает @redirect
   location / {
        try_files /wp-content/cache/supercache/${http_host}${request_uri}index.html @redirect;
   }
   
    # перенаправление на основной домен
    location @redirect {
        return 301 http://example.tdl$request_uri;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question