Javascript & Simple Cache

Hello,

before my javascript is delivered to the server, there are some php code in the file

<?php
$ts = time();
$token = generate_action_token($ts);
$url = elgg_get_site_url() . 'action/agvideo/rate?__elgg_ts='.$ts.'&__elgg_token='.$token;
?>

And  a if else

<?php if(!elgg_is_logged_in()){ ?>
    //do this javascript
<?php }else{ ?> 
  //do something else
<?php } ?>

Everything works fine, but when I turn on simle cache it won't, because only
one possibility is cached and so the time and token is wrong.
Is there a possibility to get this vars with javascript
- the token and the time
- if the user is logged in