How to Set Up PrestaShop Media Server with Cookie-free Domain via SSL

Updated on May 10, 2023

PrestaShop provides a great way to serve your content via a cookie-free domain name by using the Performance configuration settings called Media Server. Basically, setting a media server URL in your PrestaShop will improve your static content delivery, website performance, and GTMetrix, as your images, CSS, and JavaScript files will be serviced via a cookie-free domain.

Table of Contents:

What are HTTP Cookies?

An HTTP cookie is a little piece of data delivered from one webpage or website to another. When the user browses, their web browser saves this little data to their computer. Cookies' main purpose is to make browsing the Internet more convenient. The data they store will be recognised by websites you go back to in various ways. For instance, if you saved your username and password, that is stored in a cookie; or if you added items to your shopping cart, they will still be there when you return to the site, because the cookies saved them. 

A cookie-free domain is a straightforward concept. It is a domain that does not instruct a visitor's browser to store cookies from the website. Static content on our website includes photos, javascript, and CSS files. These contents do not frequently update, which is exactly why they are referred to as Static.

Because there is no user interaction with these resources, they do not require the use of cookies. So, by configuring a domain that does not set cookies, we can reduce the amount of the total requests made to our server by the visitor's browser while attempting to retrieve page resources.

The idea behind this method is to reduce server latency by minimizing the number of queries, which can have a minor influence on the speed of your website.

The Problem: High Server Latency Leads to Slow Websites

We have already covered the steps needed to configure the PrestaShop Media Server URL on the cPanel hosting account, but many customers face an issue when having this setup while using an SSL certificate for their stores. The reason for the issue is that usually, the SSL is valid for their main domain www.example.com and does not cover the Media Server subdomain used for cookie-free URLs. In this situation, you will be forced to either:

  • Consider installing or purchasing a wildcard SSL to cover your subdomains as well *.domain.com;
  • Activate Cloudflare CDN using their Universal SSL to convert your subdomain.

Both solutions have drawbacks: the WildCard SSL may be expensive, especially if you do not require SSL for your subdomains, and the Cloudflare CDN applies security cookies to all content processed through their network, so you will still have cookies applied to your static content with the second option.

Note

It is important to note that our hosting services here at FastComet offer free and reliable SSL certificates, for both a single domain and Wildcard. You can issue a Wildcard certificate for any domain which points to our hosting services at no additional cost.

The Solution: Processing Static Content via Shared SSL and mod_userdir

Most hosting providers support the Apache mod_userdir, which allows you to access your account via the server hostname using a URL such as http://hostname/~username where the ‘hostname’ is the server hostname and the ‘username’ is your cPanel username.

Additionally, most hosting providers, including FastComet, have a valid and trusted SSL certificate installed for the server hostname, usually advertised as Shared SSL. In many cases, the Shared SSL is almost useless as you will most probably not want to have your website accessed via a third-party URL different from your domain name. In this case, however, the Shared SSL can be great for processing your static content via the cookie-free domain and still keep it secure via HTTPS.

Unfortunately, PrestaShop does not accept URLs, including the ‘~’ character for the media server settings, but with just a quick trick, you can set this.

Before changing any settings on your PrestaShop installation, make sure your account is accessible via mod_userdir, and a valid SSL is available on your hosting server. You may contact your host and consult if this option is available for you. All FastComet clients on our private VPS and Dedicated Server Hosting plans can take advantage of this feature completely free of charge. If you are using one of our Shared Hosting plans, then please consider the wildcard SSL solution from above.

If your host supports mod_userdir and has a valid SSL, you can proceed to your PrestaShop admin panel, Performance section, under the Advanced Parameters menu. Scroll to the Media Servers section and input any dummy URL, such as:

static.domain.com

Contact us for Assistance

When it comes to help, we’re always ready to provide it. Contact our technical support team for assistance whenever you need it. You can do that by opening a new support ticket. Our job is to ensure that your online project is successful.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

SSD Cloud Hosting

  • Free Domain Transfer
  • 24/7 Technical Support
  • Fast SSD Storage
  • Hack-free Protection
  • Free Script Installation
  • Free Website Transfer
  • Free Cloudflare CDN
  • Immediate Activation
View More