You can, and it works. If you put Debian Squeeze on your DNS-320 (
download link - installation instructions inside), you can do a lot of things - pretty much everything you can do with a Debian installed with no graphical interface. My DNS-320 works as proxy server (Squid) and email server (Postfix/Dovecot) for almost two years now; I also have Deluge (torrents client daemon with web interface), miniDLNA and ddclient (DynDNS) installed on it.
If your NAS is behind a firewall or a router, like mine, in order to make Squid work you have to forward properly the proxy port.
Please keep in mind that it might not be the best choice, because the CPU and RAM are a little bit too
light. Also, the transfer rates between NAS and PC(s) will decrease substantially (mine have dropped at 2/3). I don't need a lot of speed, since I don't use it for backups, but... that's just me.
Good luck.