KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Serving Static Assets with 4D's built-in Web Server
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: June 22, 2001

The easiest way to increase the performance of a 4D-powered web site is to have 4D handle strictly the dynamic elements of your site. A dynamic web page is one that is generated, partially or completley, "on-the-fly" using either 4D's language or 4D Tags embedded in an HTML page sent through 4D's Web Server. The static elements (images, PDF files, MP3's, etc.) can easily be served by a traditional web server like WebSTAR.

It is nice to have the option to serve the static assets either through 4D's Web Server or WebSTAR. Normally to include an image in an HTML file served by 4D, you would write:

<img src="/image.gif">

To give you the flexibility of having the image served via another HTTP server, you might instead write the tag like this:

<img src="<!--4DVAR WEB_t_StaticRoot-->/image.gif">

where WEB_t_StaticRoot is a process variable with the value of, for example, "https://images.mydomain.com".

When 4D sends out the web page, the HTML the browser sees will read:

<img src="https://images.mydomain.com/image.gif">

You can clear out the value of WEB_t_StaticRoot as needed, making 4D the source again for the static assets.