A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [Resolved] [Resolved] Turbine.CacheMovie

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    9
    Jorge et al,

    Using the CacheMovie command, is it possible to cache many instances of the same .swt using a unique reference?

    The plan is to speed up content delivery by reducing database calls to essentially static information.

    Thanks

    Tony

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    827
    The cached movie is effectively created during the final GenerateFlash command, because of this it's only possible to cache one generated movie per .asp script invocation. Depending on the number of items to cache it might make sense to call several .asp scripts from a batch file or by using Javascript from an HTML page.

  3. #3
    Junior Member
    Join Date
    Jul 2002
    Posts
    9
    Sorry Jorge, I did not make myself too clear.

    Each time the asp page is called it creates a swf with data from a database, which varies based on a database ID, so the next time the page is called it generates the same swf but with different data.

    I would like to cache each incarnation of the swf with a reference based on the database ID that is returned. In this way I could cache all the data pages I need as they are called in a day and speed up my site considerably.

    If I could rename the swt on the fly, or generate to a different filename each time, ie data001.swf, data002.swf then this would do the same job.

    Thanks again

    Tony

  4. #4
    Junior Member
    Join Date
    Jul 2002
    Posts
    9
    Sorry Jorge, I did not make myself too clear.

    Each time the asp page is called it creates a swf with data from a database, which varies based on a database ID, so the next time the page is called it generates the same swf but with different data.

    I would like to cache each incarnation of the swf with a reference based on the database ID that is returned. In this way I could cache all the data pages I need as they are called in a day and speed up my site considerably.

    If I could rename the swt on the fly, or generate to a different filename each time, ie data001.swf, data002.swf then this would do the same job.

    Thanks again

    Tony

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Posts
    827
    But you can do that very easily, as long as you know the desired ID(s), both when creating the movie and when serving it. Two ways:
    a) You can generate to local files, once a day for example:
    ...
    'get ID for this movie
    'set variables or data sets for this ID...
    Turbine.generateToFile(ID & ".swf")

    'get another ID for this movie
    'set variables or data sets for this ID...
    Turbine.generateToFile(ID & ".swf")

    ... and so on...

    then later, on a second .asp simply redirect to the respective "*.swf", previously generated.

    b) Use the caching facilities:
    ...
    'get ID for this movie

    If (Turbine.ServeCached(ID)) Then
    ' if the movie was still cached then it was served to the user so we terminate the execution ...
    Response.End
    Else
    ' since the movie was not in the cache, then we ask for it to be cached...
    Turbine.CacheMovie ID, "010000" ' cache till next 01:00am
    End If

    ... do stuff to generate the movie based on this ID...

    ' now generate the movie to the web browser (which will also automatically cache it) ...
    Turbine.GenerateFlash


  6. #6
    Junior Member
    Join Date
    Dec 2001
    Posts
    13
    Originally posted by jdiogo
    But you can do that very easily, as long as you know the desired ID(s), both when creating the movie and when serving it. Two ways:

    b) Use the caching facilities:
    ...
    'get ID for this movie

    If (Turbine.ServeCached(ID)) Then
    ' if the movie was still cached then it was served to the user so we terminate the execution ...
    Response.End
    Else
    ' since the movie was not in the cache, then we ask for it to be cached...
    Turbine.CacheMovie ID, "010000" ' cache till next 01:00am
    End If

    ... do stuff to generate the movie based on this ID...

    ' now generate the movie to the web browser (which will also automatically cache it) ...
    Turbine.GenerateFlash
    That's what i did, and i ended up with a single directory containig +20000 files.

    Is there any improvement sceduled next time?

    Greetings,
    -tb
    "Technology is a constant battle between manufacturers producing bigger and
    more idiot-proof systems and nature producing bigger and better idiots."

  7. #7
    Senior Member
    Join Date
    Nov 2000
    Posts
    827
    That many files should be result of different IDs when caching - when a movie with the same ID is found in the cache it has already expired, Turbine will delete it before caching again.
    Please check how is it generating the IDs - a possible explanation for those files would be different IDs.

  8. #8
    Junior Member
    Join Date
    Dec 2001
    Posts
    13
    Originally posted by jdiogo
    That many files should be result of different IDs when caching - when a movie with the same ID is found in the cache it has already expired, Turbine will delete it before caching again.
    Please check how is it generating the IDs - a possible explanation for those files would be different IDs.
    Yes, these are different IDs for the same template, but this is what i need. Unfortunally accessing the cache dir is __very__ slow. Are there any improvements scheduled for next time?
    Suggestions:
    - IDs up to 1024 chars
    - squid-cache like directory structure in the cache dir
    - different cache dirs for different virtual servers (i want to use same IDs with different content on different virtual hosts)

    Greetings,
    -tb
    "Technology is a constant battle between manufacturers producing bigger and
    more idiot-proof systems and nature producing bigger and better idiots."

  9. #9
    Senior Member
    Join Date
    Nov 2000
    Posts
    827
    The ID (or reference as it's called on the docs) is the "primary key" for the caching process - each ID represents a different cached movie. Since you can use any string as the ID, to differentiate among different virtual hosts just add the SERVER_NAME (or a hash of the server name, since the ID can be up to 64 characters - Turbine 7 allows IDs up to 160 characters) to the ID used for movie caching.
    Regarding being slow - the disk caching subsystem is very light in the processing it does, we believe there's not much room for improvement on this area. And caching represents tremendous performance savings, against full movie generation...
    We'll be looking into Squid's caching capabilities - thanks for the suggestion.
    Last edited by jdiogo; 09-06-2003 at 10:34 AM.

  10. #10
    Junior Member
    Join Date
    Dec 2001
    Posts
    13
    Originally posted by jdiogo
    The ID (or reference as it's called on the docs) is the "primary key" for the caching process - each ID represents a different cached movie. Since you can use any string as the ID, to differentiate among different virtual hosts just add the SERVER_NAME (or a hash of the server name, since the ID can be up to 64 characters - Turbine 7 allows IDs up to 160 characters) to the ID used for movie caching.
    Regarding being slow - the disk caching subsystem is very light in the processing it does, we believe there's not much room for improvement on this area. And caching represents tremendous performance savings, against full movie generation...
    We'll be looking into Squid's caching capabilities - thanks for the suggestion.
    IMHO an ID string of 64 is to short. In my case i have to use a server-name of +50 chars (yes, this is stupid, but i've no chance; it wasn't my decision), a identifier for my script and up to 4 ulong int IDs for my database objects. 1024 char IDs would be really nice...

    Greetings,
    -tb
    "Technology is a constant battle between manufacturers producing bigger and
    more idiot-proof systems and nature producing bigger and better idiots."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center