{"id":331303,"date":"2022-03-31T09:01:43","date_gmt":"2022-03-31T09:01:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331303"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331303","title":{"rendered":"<span>\u041a\u044d\u0448 HTML \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 NGINX \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0438\u0437 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (PHP \u0438 \u0442.\u043f.)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f, \u0437\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f \u043a\u044d\u0448 HTML<\/h2>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f.<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c  \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u0438\u0437 Google, Facebook, TripAdvisor, Yelp \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0438 embed \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438 \u0441\u0430\u0439\u0442\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c1\/84a\/2bd\/6c184a2bd488b72dbfb4304261ff2264.png\" width=\"1028\" height=\"791\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c1\/84a\/2bd\/6c184a2bd488b72dbfb4304261ff2264.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0441\u0442\u0435\u043a\u0435 Linux, Nginx, MySql, PHP. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0432\u0438\u0434\u0436\u0435\u0442 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442, \u0432\u0438\u0434\u0436\u0435\u0442 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430. \u0418 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0440\u043e\u0441\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u044d\u0448. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 2018 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u043d\u0430 \u0442\u044d\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u044d\u0448 Laravel, \u0447\u0442\u043e\u0431 \u043e\u043d \u043f\u043e \u0443\u043c\u043d\u043e\u043c\u0443 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0412 \u0431\u044d\u043a\u043b\u043e\u0433 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u044d\u0448 HTML, \u043d\u043e, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0435 \u0431\u044b\u043b\u043e \u0431\u044e\u0434\u0436\u0435\u0442\u0430. \u0427\u0435\u0440\u0435\u0437 \u0433\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u043e\u0449\u043d\u0435\u0435.<\/p>\n<p>\u0421\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043c\u0435\u0441\u0442\u0430 \u043f\u043e\u043c\u043e\u0433 \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0440\u0435\u043a\u043b\u0430\u043c\u0443 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442 \u0438 \u043a \u043d\u0430\u043c \u0441\u0442\u0430\u043b\u043e \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 100 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0447\u0435\u043c \u0432 \u0441\u0443\u043c\u043c\u0435 \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043c\u044b \u0437\u0430\u0431\u0430\u043d\u0438\u043b\u0438 \u0432\u0438\u0434\u0436\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041d\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \ud83d\ude42<\/p>\n<p>\u041a\u044d\u0448 HTML \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PHP \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u043b. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u043f\u0430\u043b\u0430, \u0442.\u043a. \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043d\u043e \u044d\u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0431\u044b\u043b\u0430 \u0431\u044b \u043f\u043e\u043b\u0443\u043c\u0435\u0440\u0430. \u041e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0442\u043d\u0438\u043c\u0430\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<\/div>\n<\/details>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u044d\u0448 HTML, \u0431\u044b\u0441\u0442\u0440\u043e, \u0434\u0435\u0448\u0435\u0432\u043e \u0438 \u0431\u0435\u0437 \u043e\u0432\u0435\u0440\u0445\u044d\u0434\u0430.<\/h3>\n<p>\u0426\u0435\u043b\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u044d\u0448\u0430 &#8212; \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u043c \u0442\u044b\u0441\u044f\u0447 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 HTML \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0431\u0435\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f(PHP \u0438 \u0442.\u043f.)<\/p>\n<p>\u042f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0442\u043e\u0431 \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041d\u0430 \u0443\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 Varnish, \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u0437\u0430\u043c\u0430\u043d\u0447\u0438\u0432\u043e, \u043d\u043e \u043e\u043d\u0438 \u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u043e\u043c \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0438\u043b\u0438\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043b\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0442\u043e\u0436\u0435 <\/p>\n<p>\u041d\u0430\u043c \u0441 \u0442\u0440\u0443\u0434\u043e\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0433\u043e DevOps, \u043e\u043d \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c openresty (nginx\u00a0\u043d\u0430 \u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u0445), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Lua \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 Redis.<\/p>\n<p><a href=\"https:\/\/openresty.org\/en\/\" rel=\"noopener noreferrer nofollow\">https:\/\/openresty.org\/en\/<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/vdsina\/blog\/504308\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/company\/vdsina\/blog\/504308\/<\/a><\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430  &#8212; \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043a\u044d\u0448 \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u0447\u0442\u043e\u0431 \u043a\u044d\u0448 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0415\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 Laravel \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u043e \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 nginx \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Laravel<\/h2>\n<p>\u041a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, 100% \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c Url path, \u043a\u0430\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u0418 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u044d\u0448\u0435\u043c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PHP \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u0438\u0434\u0436\u0435\u0442\u0430. \u0412 \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0441\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c (\u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432)<\/p>\n<pre><code class=\"php\">EmbedRequest::firstOrCreate([   'request_url' =>  request()->path() ]);<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/755\/b75\/7a0\/755b757a0ec2218021eac8df7e516d1a.png\" alt=\"embed_requests: id, request_url\" title=\"embed_requests: id, request_url\" width=\"563\" height=\"180\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/755\/b75\/7a0\/755b757a0ec2218021eac8df7e516d1a.png\"\/><figcaption>embed_requests: id, request_url<\/figcaption><\/figure>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 <code>many_to_many<\/code>  \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0441\u0438\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0451 \u043a\u044d\u0448 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/03c\/d30\/92e\/03cd3092e084aebe3c44f64574ba5458.png\" alt=\"embed_to_embed_request: id, embed_request_id, embed_id\" title=\"embed_to_embed_request: id, embed_request_id, embed_id\" width=\"314\" height=\"204\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03c\/d30\/92e\/03cd3092e084aebe3c44f64574ba5458.png\"\/><figcaption>embed_to_embed_request: id, embed_request_id, embed_id<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 URL \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 redis key \u043f\u043e <code>request_url<\/code> \u0438 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043a\u044d\u0448.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0437\u0430\u0432\u0435\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u043b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438)<\/p>\n<pre><code class=\"php\">class EmbedRequest extends Model {     const CACHE_DELAY__REQUEST_URL = 29*60;  \/\/\u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430     public static function cacheKeyByRequestUrl($requestUrl)     {         return RedisService::KEY_PREFIX__NGINX__EMBED_PAGE_CACHE . $requestUrl;     }  \/\/\u0441\u0431\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u044d\u0448\u0430     public function flushRelatedCache()     {         \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->forget(EmbedRequest::cacheKeyByRequestUrl($this->request_url));     } }<\/code><\/pre>\n<pre><code class=\"php\">class Business extends Model {     public static $cacheIgnore = [         'created_at',         'updated_at',     ];  \/\/\u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430     public static function cacheKeyByPk($id)     {         return 'BusinessId:' . $id;     }  \/\/\u0441\u0431\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439     public function flushRelatedCache()     {         Cache::tags(Business::cacheKeyByPk($this->id))->flush();         foreach ($this->widgets as $embedable) {             if ($embedable->embed) {                 $embedable->embed->flushRelatedCache();             }         }         foreach ($this->badges as $embedable) {             if ($embedable->embed) {                 $embedable->embed->flushRelatedCache();             }         }         if ($this->collect &amp;&amp; $this->collect->embed) {             $this->collect->embed->flushRelatedCache();         }     } }<\/code><\/pre>\n<p>\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0441\u043a\u0430\u0434\u043e\u043c \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043a\u044d\u0448\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 <code>$model->flushRelatedCache()<\/code> \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 <code>$model->isDirty($cachingAttributes)<\/code><\/p>\n<pre><code class=\"php\">    public function saved($model)     {         $cachingAttributes = array_diff(array_keys($model->getAttributes()), $model::$cacheIgnore);         if($model->isDirty($cachingAttributes) ) {             $model->flushRelatedCache();         }     }<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432 \u043a\u044d\u0448<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 <code>text\/html<\/code><\/p>\n<pre><code class=\"php\">public function returnIframeView() {     $viewFolderPath = $this->resolveViewFolderPath();     $view = view($viewFolderPath, [         'badgeDataDto' => $this->getEmbedData(),         'preview'      => false,     ]);     $cacheKey = EmbedRequest::cacheKeyByRequestUrl($this->embedRequest->request_url);     $view = \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->remember($cacheKey, EmbedRequest::CACHE_DELAY__REQUEST_URL, function () use ($view) {         return $view->render();     });     return $view; }<\/code><\/pre>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 <code>application\/json<\/code><\/p>\n<pre><code class=\"php\">$responseContent = response()->json([     \"type\" => $primaryWidget->design_theme,     \"html\" => $view->render(), ]); \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->remember($cacheKey, EmbedRequest::CACHE_DELAY__REQUEST_URL, function () use ($responseContent) {     return $responseContent->content(); }); return $responseContent;<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Openresty (Nginx)<\/h2>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Openresty \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0430.<\/p>\n<p>\u043f\u043e\u0434 <code>etc\\nginx<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0434\u043b\u044f \u0438\u043d\u043a\u043b\u0443\u0434\u0430 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 nginx \u043a\u043e\u043d\u0444\u0438\u0433, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>snippets\/redis_prod.conf<\/code><\/p>\n<pre><code class=\"nginx\">server {     ...         include snippets\/redis_prod.conf;         ... }<\/code><\/pre>\n<p>\u0418 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u044f \u0432 \u041f\u0425\u041f. \u0414\u0443\u043c\u0430\u044e \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0434\u0430 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438, \u0442.\u043a. \u0432\u0441\u0451 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e (\u043a\u0430\u043a \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u043b\u044e\u0431\u043e\u0439 middle \u041f\u0425\u041f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a)<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c <em>coroutine<\/em>.<\/p>\n<pre><code class=\"nginx\">-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u0442\u0430\u043a \u0432\u0440\u043e\u0434\u0435 \u0431\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d -- \u043f\u0430\u0440\u0441\u0438\u043c URL \u0447\u0442\u043e\u0431 \u0441\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b location ~ ^\/(embed\/v2\/|embed\/|badge\/)([a-zA-Z0-9\\|]+?)[\/]?($|\\?.*) {     set $token1 $1;     set $token2 $2;     add_header Cache-Control \"no-cache, max-age=1800, must-revalidate\";     add_header Access-Control-Allow-Origin *;     lua_socket_log_errors off;  content_by_lua_block {     local redis = require \"resty.redis\"          -- \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.   -- \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. coroutine \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e     local coroutine = ngx.thread.spawn(function()         local red2 = redis:new()         red2:set_timeouts(100, 1000, 1000) -- 1 sec         local ok, err = red2:connect(\"127.0.0.1\", 6379)         if not ok then             ngx.log(ngx.ERR, err)             ngx.exec('\/index.php', ngx.var.args)         end         red2:init_pipeline()         red2:select(1)         red2:set(\"nginx:embed_page_referer:\" .. ngx.var.token1 .. ngx.var.token2, ngx.var.http_referer)         red2:incr(\"nginx:embed_page_count:\" .. ngx.var.token1 .. ngx.var.token2)         assert(red2:commit_pipeline())         red2:set_keepalive(60000, 50)     end)   -- \u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.          -- \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0440\u0435\u0434\u0438\u0441\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430     local red = redis:new()     red:set_timeouts(100, 1000, 1000) -- 1 sec     local ok, err = red:connect(\"127.0.0.1\", 6379)          -- \u043d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f - \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e     if not ok then         ngx.log(ngx.ERR, err)         ngx.exec('\/index.php', ngx.var.args)     end          -- \u0432\u044b\u0431\u043e\u0440 \u0411\u0414 \u0440\u0435\u0434\u0438\u0441\u0430     red:select(2)          -- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u044d\u0448 \u043f\u043e \u043a\u043b\u044e\u0447\u0443     local res, err = red:get(\"nginx:embed_page_cache:\" .. ngx.var.token1 .. ngx.var.token2)     red:set_keepalive(60000, 50)      -- \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0442\u043e \u0442\u0430\u043c     if res and res ~= ngx.null then         local is_html = ngx.re.find(res, [[^\\s*&amp;lt;]],  \"jo\")         if not is_html then             ngx.header.content_type = \"application\/json; charset=utf-8\"         else             ngx.header.content_type = \"text\/html; charset=utf-8\"         end         ngx.print(res)         -- ensure background coroutine finish         ngx.thread.wait(coroutine)         ngx.exit(200)     end     if err then         ngx.log(ngx.ERR, err)     end     ngx.thread.wait(coroutine)          -- \u043d\u0435\u0442 \u043a\u044d\u0448\u0430 - \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443      ngx.exec('\/index.php', ngx.var.args) } } <\/code><\/pre>\n<h2>P.S.<\/h2>\n<p>\u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u0440\u0435\u0446\u0435\u043f\u0442, \u0447\u0442\u043e\u0431 \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430\u043c, \u0433\u0434\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431 \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/563606\/\"> https:\/\/habr.com\/ru\/post\/563606\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f, \u0437\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f \u043a\u044d\u0448 HTML<\/h2>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f.<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c  \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u0438\u0437 Google, Facebook, TripAdvisor, Yelp \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0438 embed \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438 \u0441\u0430\u0439\u0442\u044b.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0441\u0442\u0435\u043a\u0435 Linux, Nginx, MySql, PHP. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0432\u0438\u0434\u0436\u0435\u0442 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442, \u0432\u0438\u0434\u0436\u0435\u0442 \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430. \u0418 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0440\u043e\u0441\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u044d\u0448. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 2018 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u043d\u0430 \u0442\u044d\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u044d\u0448 Laravel, \u0447\u0442\u043e\u0431 \u043e\u043d \u043f\u043e \u0443\u043c\u043d\u043e\u043c\u0443 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0412 \u0431\u044d\u043a\u043b\u043e\u0433 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u044d\u0448 HTML, \u043d\u043e, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0435 \u0431\u044b\u043b\u043e \u0431\u044e\u0434\u0436\u0435\u0442\u0430. \u0427\u0435\u0440\u0435\u0437 \u0433\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u043e\u0449\u043d\u0435\u0435.<\/p>\n<p>\u0421\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043c\u0435\u0441\u0442\u0430 \u043f\u043e\u043c\u043e\u0433 \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0440\u0435\u043a\u043b\u0430\u043c\u0443 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442 \u0438 \u043a \u043d\u0430\u043c \u0441\u0442\u0430\u043b\u043e \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 100 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0447\u0435\u043c \u0432 \u0441\u0443\u043c\u043c\u0435 \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043c\u044b \u0437\u0430\u0431\u0430\u043d\u0438\u043b\u0438 \u0432\u0438\u0434\u0436\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041d\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \ud83d\ude42<\/p>\n<p>\u041a\u044d\u0448 HTML \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PHP \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u043b. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0443\u043f\u0430\u043b\u0430, \u0442.\u043a. \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043d\u043e \u044d\u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0431\u044b\u043b\u0430 \u0431\u044b \u043f\u043e\u043b\u0443\u043c\u0435\u0440\u0430. \u041e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0442\u043d\u0438\u043c\u0430\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<\/div>\n<\/details>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u044d\u0448 HTML, \u0431\u044b\u0441\u0442\u0440\u043e, \u0434\u0435\u0448\u0435\u0432\u043e \u0438 \u0431\u0435\u0437 \u043e\u0432\u0435\u0440\u0445\u044d\u0434\u0430.<\/h3>\n<p>\u0426\u0435\u043b\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u044d\u0448\u0430 &#8212; \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u043c \u0442\u044b\u0441\u044f\u0447 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 HTML \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0431\u0435\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f(PHP \u0438 \u0442.\u043f.)<\/p>\n<p>\u042f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0442\u043e\u0431 \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432. \u041d\u0430 \u0443\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 Varnish, \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u0437\u0430\u043c\u0430\u043d\u0447\u0438\u0432\u043e, \u043d\u043e \u043e\u043d\u0438 \u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u043e\u043c \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0438\u043b\u0438\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043b\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0442\u043e\u0436\u0435 <\/p>\n<p>\u041d\u0430\u043c \u0441 \u0442\u0440\u0443\u0434\u043e\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0433\u043e DevOps, \u043e\u043d \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c openresty (nginx\u00a0\u043d\u0430 \u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u0445), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Lua \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 Redis.<\/p>\n<p><a href=\"https:\/\/openresty.org\/en\/\" rel=\"noopener noreferrer nofollow\">https:\/\/openresty.org\/en\/<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/vdsina\/blog\/504308\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/company\/vdsina\/blog\/504308\/<\/a><\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430  &#8212; \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043a\u044d\u0448 \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u0447\u0442\u043e\u0431 \u043a\u044d\u0448 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0415\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 Laravel \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u043e \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 nginx \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Laravel<\/h2>\n<p>\u041a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, 100% \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c Url path, \u043a\u0430\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u0418 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u044d\u0448\u0435\u043c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PHP \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u0438\u0434\u0436\u0435\u0442\u0430. \u0412 \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0441\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c (\u0443 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432)<\/p>\n<pre><code class=\"php\">EmbedRequest::firstOrCreate([   'request_url' =>  request()->path() ]);<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>embed_requests: id, request_url<\/figcaption><\/figure>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 <code>many_to_many<\/code>  \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0441\u0438\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0451 \u043a\u044d\u0448 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445. <\/p>\n<figure class=\"\"><figcaption>embed_to_embed_request: id, embed_request_id, embed_id<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 URL \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 redis key \u043f\u043e <code>request_url<\/code> \u0438 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043a\u044d\u0448.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0437\u0430\u0432\u0435\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u043b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438)<\/p>\n<pre><code class=\"php\">class EmbedRequest extends Model {     const CACHE_DELAY__REQUEST_URL = 29*60;  \/\/\u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430     public static function cacheKeyByRequestUrl($requestUrl)     {         return RedisService::KEY_PREFIX__NGINX__EMBED_PAGE_CACHE . $requestUrl;     }  \/\/\u0441\u0431\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u044d\u0448\u0430     public function flushRelatedCache()     {         \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->forget(EmbedRequest::cacheKeyByRequestUrl($this->request_url));     } }<\/code><\/pre>\n<pre><code class=\"php\">class Business extends Model {     public static $cacheIgnore = [         'created_at',         'updated_at',     ];  \/\/\u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430     public static function cacheKeyByPk($id)     {         return 'BusinessId:' . $id;     }  \/\/\u0441\u0431\u0440\u043e\u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439     public function flushRelatedCache()     {         Cache::tags(Business::cacheKeyByPk($this->id))->flush();         foreach ($this->widgets as $embedable) {             if ($embedable->embed) {                 $embedable->embed->flushRelatedCache();             }         }         foreach ($this->badges as $embedable) {             if ($embedable->embed) {                 $embedable->embed->flushRelatedCache();             }         }         if ($this->collect &amp;&amp; $this->collect->embed) {             $this->collect->embed->flushRelatedCache();         }     } }<\/code><\/pre>\n<p>\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0441\u043a\u0430\u0434\u043e\u043c \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043a\u044d\u0448\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 <code>$model->flushRelatedCache()<\/code> \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 <code>$model->isDirty($cachingAttributes)<\/code><\/p>\n<pre><code class=\"php\">    public function saved($model)     {         $cachingAttributes = array_diff(array_keys($model->getAttributes()), $model::$cacheIgnore);         if($model->isDirty($cachingAttributes) ) {             $model->flushRelatedCache();         }     }<\/code><\/pre>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432 \u043a\u044d\u0448<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 <code>text\/html<\/code><\/p>\n<pre><code class=\"php\">public function returnIframeView() {     $viewFolderPath = $this->resolveViewFolderPath();     $view = view($viewFolderPath, [         'badgeDataDto' => $this->getEmbedData(),         'preview'      => false,     ]);     $cacheKey = EmbedRequest::cacheKeyByRequestUrl($this->embedRequest->request_url);     $view = \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->remember($cacheKey, EmbedRequest::CACHE_DELAY__REQUEST_URL, function () use ($view) {         return $view->render();     });     return $view; }<\/code><\/pre>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 <code>application\/json<\/code><\/p>\n<pre><code class=\"php\">$responseContent = response()->json([     \"type\" => $primaryWidget->design_theme,     \"html\" => $view->render(), ]); \\Cache::store(RedisService::CACHE_STORAGE__REDIS_RAW)->remember($cacheKey, EmbedRequest::CACHE_DELAY__REQUEST_URL, function () use ($responseContent) {     return $responseContent->content(); }); return $responseContent;<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Openresty (Nginx)<\/h2>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Openresty \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0430.<\/p>\n<p>\u043f\u043e\u0434 <code>etc\\nginx<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0434\u043b\u044f \u0438\u043d\u043a\u043b\u0443\u0434\u0430 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 nginx \u043a\u043e\u043d\u0444\u0438\u0433, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>snippets\/redis_prod.conf<\/code><\/p>\n<pre><code class=\"nginx\">server {     ...         include snippets\/redis_prod.conf;         ... }<\/code><\/pre>\n<p>\u0418 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u044f \u0432 \u041f\u0425\u041f. \u0414\u0443\u043c\u0430\u044e \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0434\u0430 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438, \u0442.\u043a. \u0432\u0441\u0451 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e (\u043a\u0430\u043a \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u043b\u044e\u0431\u043e\u0439 middle \u041f\u0425\u041f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a)<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c <em>coroutine<\/em>.<\/p>\n<pre><code class=\"nginx\">-- \u0414\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u0442\u0430\u043a \u0432\u0440\u043e\u0434\u0435 \u0431\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d -- \u043f\u0430\u0440\u0441\u0438\u043c URL \u0447\u0442\u043e\u0431 \u0441\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b location ~ ^\/(embed\/v2\/|embed\/|badge\/)([a-zA-Z0-9\\|]+?)[\/]?($|\\?.*) {     set $token1 $1;     set $token2 $2;     add_header Cache-Control \"no-cache, max-age=1800, must-revalidate\";     add_header Access-Control-Allow-Origin *;     lua_socket_log_errors off;  content_by_lua_block {     local redis = require \"resty.redis\"          -- \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.   -- \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. coroutine \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e     local coroutine = ngx.thread.spawn(function()         local red2 = redis:new()         red2:set_timeouts(100, 1000, 1000) -- 1 sec         local ok, err = red2:connect(\"127.0.0.1\", 6379)         if not ok then             ngx.log(ngx.ERR, err)             ngx.exec('\/index.php', ngx.var.args)         end         red2:init_pipeline()         red2:select(1)         red2:set(\"nginx:embed_page_referer:\" .. ngx.var.token1 .. ngx.var.token2, ngx.var.http_referer)         red2:incr(\"nginx:embed_page_count:\" .. ngx.var.token1 .. ngx.var.token2)         assert(red2:commit_pipeline())         red2:set_keepalive(60000, 50)     end)   -- \u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.          -- \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0440\u0435\u0434\u0438\u0441\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430     local red = redis:new()     red:set_timeouts(100, 1000, 1000) -- 1 sec     local ok, err = red:connect(\"127.0.0.1\", 6379)          -- \u043d\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f - \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e     if not ok then         ngx.log(ngx.ERR, err)         ngx.exec('\/index.php', ngx.var.args)     end          -- \u0432\u044b\u0431\u043e\u0440 \u0411\u0414 \u0440\u0435\u0434\u0438\u0441\u0430     red:select(2)          -- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u044d\u0448 \u043f\u043e \u043a\u043b\u044e\u0447\u0443     local res, err = red:get(\"nginx:embed_page_cache:\" .. ngx.var.token1 .. ngx.var.token2)     red:set_keepalive(60000, 50)      -- \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0442\u043e \u0442\u0430\u043c     if res and res ~= ngx.null then         local is_html = ngx.re.find(res, [[^\\s*&amp;lt;]],  \"jo\")         if not is_html then             ngx.header.content_type = \"application\/json; charset=utf-8\"         else             ngx.header.content_type = \"text\/html; charset=utf-8\"         end         ngx.print(res)         -- ensure background coroutine finish         ngx.thread.wait(coroutine)         ngx.exit(200)     end     if err then         ngx.log(ngx.ERR, err)     end     ngx.thread.wait(coroutine)          -- \u043d\u0435\u0442 \u043a\u044d\u0448\u0430 - \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443      ngx.exec('\/index.php', ngx.var.args) } } <\/code><\/pre>\n<h2>P.S.<\/h2>\n<p>\u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u0440\u0435\u0446\u0435\u043f\u0442, \u0447\u0442\u043e\u0431 \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430\u043c, \u0433\u0434\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431 \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/563606\/\"> https:\/\/habr.com\/ru\/post\/563606\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331303","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331303"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331303\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}