Configuring Caching
Enabling content caching on publishing points allows cache proxy servers to store content locally, reducing the bandwidth and resource usage on the main server. Content caching requires a cache proxy plug-in. Windows Media Services does not include a cache proxy plug-in, but you can make your own. For more information, see Creating Cache Proxy Plug-ins. You can use the AllowContentCaching property on the IWMSOnDemandPublishingPoint interface to enable caching. This is illustrated by the following examples.
Visual Basic .NET Example
Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices
' Declare variables.
Dim Server As WMSServer
Dim ODPubPoint As IWMSOnDemandPublishingPoint
Try
' Create the WMSServer object.
Server = New WMSServer()
' Retrieve the first publishing point.
ODPubPoint = Server.PublishingPoints.Item(0)
' Set this publishing point to allow cache proxy
' servers to cache content.
ODPubPoint.AllowContentCaching = True
Catch errCom As COMException
' TODO: Handle COM exceptions.
Catch err As Exception
' TODO: Exception handler goes here.
Finally
' TODO: Clean-up code goes here.
End Try
C# Example
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
// Declare variables.
WMSServer Server;
IWMSOnDemandPublishingPoint ODPubPoint;
try
{
// Create the WMSServer object.
Server = new WMSServerClass();
// Retrieve the first publishing point.
ODPubPoint = (IWMSOnDemandPublishingPoint)Server.PublishingPoints[0];
// Set this publishing point to allow cache proxy
// servers to cache content.
ODPubPoint.AllowContentCaching = true;
}
catch (COMException comExc)
{
// TODO: Handle COM exceptions.
}
catch (Exception exc)
{
// TODO: Exception handler goes here.
}
finally
{
// TODO: Clean-up code goes here.
}
C++ Example
#include <windows.h>
#include <atlbase.h> // Includes CComVariant.
#include "wmsserver.h"
// Declare variables and interfaces.
IWMSServer *pServer;
IWMSPublishingPoints *pPubPoints;
IWMSPublishingPoint *pPubPoint;
IWMSOnDemandPublishingPoint *pODPubPoint;
HRESULT hr;
CComVariant varIndex;
long lCount;
// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
NULL,
CLSCTX_ALL,
IID_IWMSServer,
(void **)&pServer);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to the IWMSPublishingPoints interface.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
// Retrieve the total count of publishing points.
hr = pPubPoints->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to the first publishing point.
varIndex = 0;
hr = pPubPoints->get_Item(varIndex, &pPubPoint);
if (FAILED(hr)) goto EXIT;
// Query a pointer to an IWMSOnDemandPublishingPoint interface.
hr = pPubPoint->QueryInterface(IID_IWMSOnDemandPublishingPoint,
(void **)&pODPubPoint);
if (FAILED(hr)) goto EXIT;
// Set this publishing point to allow cache proxy
// servers to cache its contents.
hr = pODPubPoint->put_AllowContentCaching(VARIANT_TRUE);
if (FAILED(hr)) goto EXIT;
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
See Also (General)
See Also (Visual Basic .NET)
IWMSOnDemandPublishingPoint IWMSOnDemandPublishingPoint Object (Visual Basic .NET)
IWMSPublishingPoint IWMSPublishingPoint Object (Visual Basic .NET)
See Also (C#)
IWMSOnDemandPublishingPoint IWMSOnDemandPublishingPoint Object (C#)
IWMSPublishingPoint IWMSPublishingPoint Object (C#)
See Also (C++)
IWMSOnDemandPublishingPoint IWMSOnDemandPublishingPoint Interface
IWMSPublishingPoint IWMSPublishingPoint Interface