Media Storage Database Setup

By default, all images, compiled CSS files, and compiled JavaScript files of the Magento
instance are stored in the file system on the web server. You can choose to store these files in a
database on a database server. One advantage of this approach is the option of automatic
synchronization and reverse synchronization between the web server file system and the
database. You can use the default database to store media or create a new one. To be able to use
a newly created database as media storage, you must add information about it and its access
credentials to the local.xml file.

Database Workflow

When the customer opens the store page, its browser requests the HTML code and the media
specified in the HTML code from the Magento system. The system searches the requested
media in the file system and passes it to the browser, if it is found. If the system does not find
the media in the file system, it requests the media from the database specified in the settings,
places the media to the file system, and sends it to the customer’s web browser.
To get the files from the database to the file system on the web server a PHP script is used.
When the browser requests media from the web server, there are two alternatives for when a
PHP script is run:

  • If web server rewrites are enabled in the Magento system and supported by the server, the
    PHP script is run only when the requested media is not found in the web server file system.
  • If web server rewrites are disabled in the Magento system or not supported by the server, the
    PHP script is run in any case, even when the required media exists in the file system of the
    web server.

To use a database for media storage:

1. On the Admin menu, select System > Configuration.
2. In the panel on the left, under Advanced, select System.
3. This configuration takes place at the global level, so set Current Configuration Scope to
“Default Config.”
4. Click to expand the Storage Configuration for Media section. Then, do the following:

a. Set Media Storage to “Database.”
b. Set Select Media Database to the database you want to use.
c. Click the Synchronize button to transfer the existing media to the newly selected
d. Enter the Environment Update Time in seconds.
5. When complete, click the Save Config button.

Leave a Comment

Your email address will not be published. Required fields are marked *