{"id":319901,"date":"2014-04-30T19:46:06","date_gmt":"2014-04-30T17:46:06","guid":{"rendered":"https:\/\/wp-rocket.me\/blog\/?p=136"},"modified":"2023-08-29T12:20:05","modified_gmt":"2023-08-29T10:20:05","slug":"mount-folder-ram","status":"publish","type":"post","link":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/","title":{"rendered":"How to mount a folder directly into the RAM?"},"content":{"rendered":"<p>Note : This tricks is only suitable for dedicated servers<\/p><p>A static cache system like WP Rocket stores all the website pages as HTML files.<\/p><p>Without a cache system, when a visitor access a webpage, WordPress loads first. Then, WordPress queries the database to find out which themes and plugins are to load. Finally, it loads the contents of the current page (with database requests).<\/p><p>Sometimes, this mechanism can be very long. SQL language (for communication with the database) is often a bottleneck.<\/p><p>A cache system saves each page directly in the server (HTML files). Thus when a visitor requests a page, the stored file will be directly displayed without any database requests.<\/p><p>The HTML files are stored on the server, displaying the web page will be dependent on the hard drive reading speed (and writing for saving pages).<\/p><p>The best solution is to use SSD for excellent performance compared to HDD.<\/p><p>Problem ? SSD are more expensive, and still less common than mechanical drives.<\/p><p>To take advantage of good performance if you are using a HDD a good solution is to mount the cache folder directly in your RAM. You can save several precious milliseconds with this solution.<\/p><p>It is a common practice we use for files of low importance. Indeed if you restart the server all the data in the RAM is flushed due to the <strong>lack of persistence<\/strong>.<\/p><p>The cache files are automatically regenerated, so it\u2019s doesn\u2019t really matter if you loose it.<\/p><h2 class=\"wp-block-heading\">How do we do this?<\/h2><p>We will simply create a <strong>tmpfs volume<\/strong> and mount it.<\/p><p>Tmpfs is a filesystem which was originally scheduled to store temporary files (tmp) as the same suggest.<br>Be careful, the following commands require SSH access and root privileges.<\/p><p>Here is the command:<\/p><div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">mount -t tmpfs -o size=1G tmpfs \/mywebsite\/wp-content\/cache\/wp-rocket<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div><p>Mount to create a montage point<\/p><ul class=\"wp-block-list\"><li>-t to specify filetype<\/li>\n\n<li>-o to specify options including size you want to allocate.<\/li><\/ul><p>You should customize the size options depending how much free ram you have.<\/p><p>Be careful, don\u2019t forget to specify the full path of your cache folder. For instance \/var\/www\/mywebsite<\/p><p>The cache folder will be mounted temporary, and won\u2019t be mounted at the next reboot.<br>To mount automatically, simply edit the fstab file (\/etc\/fstab) and add :<\/p><div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-bash code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-bash code-embed-code\">tmpfs \/mywebsite\/wp-content\/cache\/wp-rocket tmpfs defaults,size=1G 0 0<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div><div id=\"om-ulrdquoprwqcywqbbgci-holder\"><\/div>\n\t<script>(function (d, u, ac) {\n\t\t\tvar s = d.createElement('script')\n\t\t\ts.type = 'text\/javascript'\n\t\t\ts.src = 'https:\/\/a.omappapi.com\/app\/js\/api.min.js'\n\t\t\ts.async = true\n\t\t\ts.dataset.user = u\n\t\t\ts.dataset.campaign = ac\n\t\t\td.getElementsByTagName('head')[0].appendChild(s)\n\t\t})(document, 20440, 'ulrdquoprwqcywqbbgci')<\/script>","protected":false},"excerpt":{"rendered":"<p>Learn how to add the cache folder directly into the RAM of a dedicated server.<\/p>\n","protected":false},"author":4,"featured_media":319038,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"kia_subtitle":"","footnotes":""},"categories":[63],"tags":[],"class_list":["post-319901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-cache"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mount a folder into the RAM with TMPFS<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mount a folder into the RAM with TMPFS\" \/>\n<meta property=\"og:description\" content=\"Learn how to add the cache folder directly into the RAM of a dedicated server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Rocket\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-30T17:46:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-29T10:20:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jean-Baptiste\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:site\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jean-Baptiste\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\"},\"author\":{\"name\":\"Jean-Baptiste\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/ce96699510f67936972f2c315283f499\"},\"headline\":\"How to mount a folder directly into the RAM?\",\"datePublished\":\"2014-04-30T17:46:06+00:00\",\"dateModified\":\"2023-08-29T10:20:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\"},\"wordCount\":385,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg\",\"articleSection\":[\"Page speed and caching\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\",\"url\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\",\"name\":\"Mount a folder into the RAM with TMPFS\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg\",\"datePublished\":\"2014-04-30T17:46:06+00:00\",\"dateModified\":\"2023-08-29T10:20:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg\",\"width\":800,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wp-rocket.me\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Page speed and caching\",\"item\":\"https:\/\/wp-rocket.me\/blog\/wordpress-cache\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to mount a folder directly into the RAM?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wp-rocket.me\/#website\",\"url\":\"https:\/\/wp-rocket.me\/\",\"name\":\"WP Rocket\",\"description\":\"Plugin d&#039;optimisation de sites WordPress\",\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wp-rocket.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/wp-rocket.me\/#organization\",\"name\":\"WP Rocket\",\"url\":\"https:\/\/wp-rocket.me\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"width\":150,\"height\":41,\"caption\":\"WP Rocket\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\",\"https:\/\/x.com\/wp_rocket\",\"https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/ce96699510f67936972f2c315283f499\",\"name\":\"Jean-Baptiste\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b588b16dcfd0f6181e3eb8429d11eb5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b588b16dcfd0f6181e3eb8429d11eb5?s=96&d=mm&r=g\",\"caption\":\"Jean-Baptiste\"},\"description\":\"Co-Founder and CEO of WP Media\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mount a folder into the RAM with TMPFS","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/","og_locale":"en_US","og_type":"article","og_title":"Mount a folder into the RAM with TMPFS","og_description":"Learn how to add the cache folder directly into the RAM of a dedicated server.","og_url":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/","og_site_name":"WP Rocket","article_publisher":"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","article_published_time":"2014-04-30T17:46:06+00:00","article_modified_time":"2023-08-29T10:20:05+00:00","og_image":[{"width":800,"height":300,"url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg","type":"image\/jpeg"}],"author":"Jean-Baptiste","twitter_card":"summary_large_image","twitter_creator":"@wp_rocket","twitter_site":"@wp_rocket","twitter_misc":{"Written by":"Jean-Baptiste","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#article","isPartOf":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/"},"author":{"name":"Jean-Baptiste","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/ce96699510f67936972f2c315283f499"},"headline":"How to mount a folder directly into the RAM?","datePublished":"2014-04-30T17:46:06+00:00","dateModified":"2023-08-29T10:20:05+00:00","mainEntityOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/"},"wordCount":385,"commentCount":8,"publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg","articleSection":["Page speed and caching"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/","url":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/","name":"Mount a folder into the RAM with TMPFS","isPartOf":{"@id":"https:\/\/wp-rocket.me\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg","datePublished":"2014-04-30T17:46:06+00:00","dateModified":"2023-08-29T10:20:05+00:00","breadcrumb":{"@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#primaryimage","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2\/full-potential.jpg","width":800,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/wp-rocket.me\/blog\/mount-folder-ram\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-rocket.me"},{"@type":"ListItem","position":2,"name":"Page speed and caching","item":"https:\/\/wp-rocket.me\/blog\/wordpress-cache\/"},{"@type":"ListItem","position":3,"name":"How to mount a folder directly into the RAM?"}]},{"@type":"WebSite","@id":"https:\/\/wp-rocket.me\/#website","url":"https:\/\/wp-rocket.me\/","name":"WP Rocket","description":"Plugin d&#039;optimisation de sites WordPress","publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-rocket.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-rocket.me\/#organization","name":"WP Rocket","url":"https:\/\/wp-rocket.me\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","width":150,"height":41,"caption":"WP Rocket"},"image":{"@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","https:\/\/x.com\/wp_rocket","https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q"]},{"@type":"Person","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/ce96699510f67936972f2c315283f499","name":"Jean-Baptiste","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b588b16dcfd0f6181e3eb8429d11eb5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b588b16dcfd0f6181e3eb8429d11eb5?s=96&d=mm&r=g","caption":"Jean-Baptiste"},"description":"Co-Founder and CEO of WP Media"}]}},"_links":{"self":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/319901"}],"collection":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/comments?post=319901"}],"version-history":[{"count":0,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/319901\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media\/319038"}],"wp:attachment":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media?parent=319901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/categories?post=319901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/tags?post=319901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}